initial implementation of attachmentsetting
This commit is contained in:
parent
d8ed541d12
commit
9aaa8a86f5
6 changed files with 134 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// 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.
|
||||
const fileType = mimetype => {
|
||||
export const fileType = mimetype => {
|
||||
if (mimetype.match(/flash/)) {
|
||||
return 'flash'
|
||||
}
|
||||
|
|
@ -25,11 +25,25 @@ const fileType = mimetype => {
|
|||
return 'unknown'
|
||||
}
|
||||
|
||||
const fileMatchesSomeType = (types, file) =>
|
||||
export const fileTypeExt = url => {
|
||||
if (url.match(/\.(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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue