Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F325897
file_type.service.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
file_type.service.js
View Options
// TODO this func might as well take the entire file and use its mimetype
// or the entire service could be just mimetype service that only operates
// on mimetypes and not files. Currently the naming is confusing.
export
const
fileType
=
mimetype
=>
{
if
(
mimetype
.
match
(
/flash/
))
{
return
'flash'
}
if
(
mimetype
.
match
(
/text\/html/
))
{
return
'html'
}
if
(
mimetype
.
match
(
/image/
))
{
return
'image'
}
if
(
mimetype
.
match
(
/video/
))
{
return
'video'
}
if
(
mimetype
.
match
(
/audio/
))
{
return
'audio'
}
return
'unknown'
}
export
const
fileTypeExt
=
url
=>
{
if
(
url
.
match
(
/\.(a?png|jpe?g|gif|webp|avif)$/
))
{
return
'image'
}
if
(
url
.
match
(
/\.(ogv|mp4|webm|mov)$/
))
{
return
'video'
}
if
(
url
.
match
(
/\.(it|s3m|mod|umx|mp3|aac|m4a|flac|alac|ogg|oga|opus|wav|ape|midi?)$/
))
{
return
'audio'
}
return
'unknown'
}
export
const
fileMatchesSomeType
=
(
types
,
file
)
=>
types
.
some
(
type
=>
fileType
(
file
.
mimetype
)
===
type
)
const
fileTypeService
=
{
fileType
,
fileTypeExt
,
fileMatchesSomeType
}
export
default
fileTypeService
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 24, 4:27 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
95555
Default Alt Text
file_type.service.js (1 KB)
Attached To
Mode
rPUFE pleroma-fe-upstream
Attached
Detach File
Event Timeline
Log In to Comment