stargaze-studio/utils/getAssetType.ts
Serkan Reis 986777b73d
Use "animation_url" in the uploaded metadata for storing media file URIs (#27)
* Remove image and animation_url from metadata modal

* Use animation_url for storing audio and video asset URIs

* Use image and animation_url keys together for audio/video assets

* Delete empty metadata keys

* Post-review update
2022-08-09 12:08:10 +03:00

12 lines
560 B
TypeScript

/* eslint-disable eslint-comments/disable-enable-pair */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
export type AssetType = 'image' | 'audio' | 'video' | 'unknown'
export const getAssetType = (assetFileName: string): AssetType => {
const assetType = assetFileName?.split('.').pop() || 'unknown'
if (assetType === 'png' || assetType === 'jpg' || assetType === 'jpeg' || assetType === 'svg') return 'image'
if (assetType === 'mp3' || assetType === 'wav') return 'audio'
if (assetType === 'mp4') return 'video'
return 'unknown'
}