Tizen Native API  7.0
MIME Type

The MIME Type API provides functions to map MIME types to file extensions and vice versa.

Required Header

#include <mime_type.h>

Overview

The MIME Type API provides functions to map MIME types to file extensions and vice versa. Conversions are provided from file extensions to MIME types and from MIME types to file extensions.
Note that some MIME types have multiple file extensions or no extension, and the MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats

Functions

int mime_type_get_mime_type (const char *file_extension, char **mime_type)
 Gets the MIME type for the given file extension.
int mime_type_get_file_extension (const char *mime_type, char ***file_extension, int *length)
 Gets the file extensions for the given MIME type.
int mime_type_get_mime_type_for_data (const void *data, size_t len, char **mime_type)
 Gets the MIME type for the given data.
int mime_type_get_mime_type_for_file (const char *file_path, char **mime_type)
 Gets the MIME type for the given file path.

Enumeration Type Documentation

Enumeration of error code.

Since :
2.3.1
Enumerator:
MIME_TYPE_ERROR_NONE 

Successful

MIME_TYPE_ERROR_INVALID_PARAMETER 

Invalid parameter

MIME_TYPE_ERROR_OUT_OF_MEMORY 

Out of memory

MIME_TYPE_ERROR_IO_ERROR 

Internal I/O error

MIME_TYPE_ERROR_PERMISSION_DENIED 

No access for the file (Since 4.0)


Function Documentation

int mime_type_get_file_extension ( const char *  mime_type,
char ***  file_extension,
int *  length 
)

Gets the file extensions for the given MIME type.

Since :
2.3.1
Remarks:
The file_extension must be released with free() by you.
Parameters:
[in]mime_typeThe MIME type
[out]file_extensionThe array of file extension without the leading dot ('.')
[out]lengthThe length of the array of file extension or zero if there is none
Returns:
0 on success, otherwise a negative error value.
Return values:
MIME_TYPE_ERROR_NONESuccessful
MIME_TYPE_ERROR_INVALID_PARAMETERInvalid parameter
MIME_TYPE_ERROR_OUT_OF_MEMORYOut of memory
MIME_TYPE_ERROR_IO_ERRORInternal I/O error
See also:
mime_type_get_mime_type()
int mime_type_get_mime_type ( const char *  file_extension,
char **  mime_type 
)

Gets the MIME type for the given file extension.

Since :
2.3.1
Remarks:
The mime_type must be released with free() by you.
Parameters:
[in]file_extensionThe file extension without the leading dot ('.')
[out]mime_typeThe MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
Returns:
0 on success, otherwise a negative error value.
Return values:
MIME_TYPE_ERROR_NONESuccessful
MIME_TYPE_ERROR_INVALID_PARAMETERInvalid parameter
MIME_TYPE_ERROR_OUT_OF_MEMORYOut of memory
MIME_TYPE_ERROR_IO_ERRORInternal I/O error
See also:
mime_type_get_file_extension()
int mime_type_get_mime_type_for_data ( const void *  data,
size_t  len,
char **  mime_type 
)

Gets the MIME type for the given data.

Since :
4.0
Remarks:
The mime_type must be released with free() by you.
Parameters:
[in]dataThe stream of file data
[in]lenThe length of data
[out]mime_typeThe MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
Returns:
0 on success, otherwise a negative error value.
Return values:
MIME_TYPE_ERROR_NONESuccessful
MIME_TYPE_ERROR_INVALID_PARAMETERInvalid parameter
MIME_TYPE_ERROR_OUT_OF_MEMORYOut of memory
MIME_TYPE_ERROR_IO_ERRORInternal I/O error
int mime_type_get_mime_type_for_file ( const char *  file_path,
char **  mime_type 
)

Gets the MIME type for the given file path.

Since :
4.0
Remarks:
The mime_type must be released with free() by you.
http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage.
http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage.
Parameters:
[in]file_pathThe path of target file
[out]mime_typeThe MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
Returns:
0 on success, otherwise a negative error value.
Return values:
MIME_TYPE_ERROR_NONESuccessful
MIME_TYPE_ERROR_INVALID_PARAMETERInvalid parameter
MIME_TYPE_ERROR_OUT_OF_MEMORYOut of memory
MIME_TYPE_ERROR_IO_ERRORInternal I/O error
MIME_TYPE_ERROR_PERMISSION_DENIEDPermission denied