@@ -12,19 +12,19 @@ const _MIMEOverrides = OrderedDict{DataType, MIME}(
1212)
1313
1414"""
15- format_to_mime (::Type{DataFormat{S}}) -> MIME
15+ getMimetype (::Type{DataFormat{S}}) -> MIME
1616
1717Get the MIME type for a FileIO `DataFormat`. Uses FileIO's extension registry
1818and MIMEs.jl for standard types, falls back to `_MIMEOverrides` for
1919domain-specific formats.
2020
2121# Examples
2222```julia
23- format_to_mime (format"PNG") # MIME("image/png")
24- format_to_mime (format"JSON") # MIME("application/json")
23+ getMimetype (format"PNG") # MIME("image/png")
24+ getMimetype (format"JSON") # MIME("application/json")
2525```
2626"""
27- function format_to_mime (:: Type{DataFormat{S}} ) where {S}
27+ function getMimetype (:: Type{DataFormat{S}} ) where {S}
2828 T = DataFormat{S}
2929 haskey (_MIMEOverrides, T) && return _MIMEOverrides[T]
3030 try
@@ -39,7 +39,7 @@ function format_to_mime(::Type{DataFormat{S}}) where {S}
3939end
4040
4141"""
42- mime_to_format (::MIME) -> Union{Type{DataFormat{S}}, Nothing}
42+ getDataFormat (::MIME) -> Union{Type{DataFormat{S}}, Nothing}
4343
4444Get the FileIO `DataFormat` for a MIME type. Uses MIMEs.jl and FileIO's extension
4545registry, falls back to `_MIMEOverrides`.
@@ -48,11 +48,11 @@ Returns `nothing` if no matching format is found.
4848
4949# Examples
5050```julia
51- mime_to_format (MIME("image/png")) # format"PNG"
52- mime_to_format (MIME("application/json")) # format"JSON"
51+ getDataFormat (MIME("image/png")) # format"PNG"
52+ getDataFormat (MIME("application/json")) # format"JSON"
5353```
5454"""
55- function mime_to_format (m:: MIME )
55+ function getDataFormat (m:: MIME )
5656 for (fmt, mime) in _MIMEOverrides
5757 mime == m && return fmt
5858 end
@@ -78,14 +78,14 @@ function unpackBlob end
7878unpackBlob (mime:: String , blob) = unpackBlob (MIME (mime), blob)
7979
8080function unpackBlob (T:: MIME , blob)
81- dataformat = mime_to_format (T)
81+ dataformat = getDataFormat (T)
8282 isnothing (dataformat) && error (" Format not found for MIME type $(T) " )
8383 return unpackBlob (dataformat, blob)
8484end
8585
8686# 1. JSON strings are saved as is
8787function packBlob (:: Type{format"JSON"} , json_str:: String )
88- mimetype = format_to_mime (format " JSON" )
88+ mimetype = getMimetype (format " JSON" )
8989 blob = Vector {UInt8} (json_str)
9090 return blob, mimetype
9191end
@@ -102,7 +102,7 @@ function packBlob(::Type{T}, data::Any; kwargs...) where {T <: DataFormat}
102102 io = IOBuffer ()
103103 save (Stream {T} (io), data; kwargs... )
104104 blob = take! (io)
105- mimetype = format_to_mime (T)
105+ mimetype = getMimetype (T)
106106 return blob, mimetype
107107end
108108
@@ -119,5 +119,5 @@ Detect the MIME type of data in an IO stream using FileIO's format detection.
119119function getMimetype (io:: IO )
120120 _getFormat (s:: FileIO.Stream{T} ) where {T} = T
121121 stream = FileIO. query (io)
122- return format_to_mime (_getFormat (stream))
122+ return getMimetype (_getFormat (stream))
123123end
0 commit comments