cr_check_mime_type (public)
cr_check_mime_type [ -mime_type mime_type ] [ -filename filename ] \ [ -file file ]
Defined in packages/acs-content-repository/tcl/revision-procs.tcl
Check whether the mimetype is registered. If not, check whether it can be guessed from the filename. If guessed mimetype is not registered optionally insert it.
- Switches:
- -mime_type (optional)
- param The mime type
- -filename (optional)
- the filename
- -file (optional)
- the actual file being saved. This option currently doesn't have any effect, but in the future would be better to inspect the actual file content instead of trusting the user.
- Returns:
- the mapped mimetype
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- xotcl_core_tutorial_4, test_cr_items
Source code: # # Check if the provided mime_type is already in our cr_mime_types # table. If so, accept it. # if {$mime_type ne "*/*" && [db_0or1row check_given_mime_type { select 1 from cr_mime_types where mime_type = :mime_type }]} { return $mime_type } # TODO: we use only the extension to get the mimetype. Something # better should be done, like inspecting the actual content of the # file and never trust the user on this regard, but as this # involves changes also in the data model, we leave this for the # future. Usages of this proc in the systems are already set to # give us the path to the file here. set extension [string tolower [string trimleft [file extension $filename] "."]] if {[db_0or1row lookup_mimetype { select mime_type from cr_extension_mime_type_map where extension = :extension }]} { return $mime_type } set mime_type [string tolower [ns_guesstype $filename]] if {[db_0or1row lookup_mimetype { select mime_type from cr_extension_mime_type_map where extension = :extension }]} { return $mime_type } set allow_mimetype_creation_p [parameter::get -parameter AllowMimeTypeCreationP -default 0] return [cr_filename_to_mime_type -create=$allow_mimetype_creation_p $filename]XQL Not present: Generic PostgreSQL XQL file: packages/acs-content-repository/tcl/revision-procs-postgresql.xql
Oracle XQL file: packages/acs-content-repository/tcl/revision-procs-oracle.xql