stargaze-studio/utils/getAssetType.ts
Serkan Reis 37f9d56d49
Preview & upload support for audio & video files (#14)
* Accept audio & video files for upload

* Rename image related variables

* Implement getAssetType util

* Preview & upload support for video files

* Preview & upload support for audio files

* Preview update for audio files

* New look for audio previews on asset list

* Remove extra refs

Co-authored-by: findolor <anakisci@gmail.com>
2022-08-03 09:31:35 +03:00

12 lines
537 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') return 'image'
if (assetType === 'mp3' || assetType === 'wav') return 'audio'
if (assetType === 'mp4') return 'video'
return 'unknown'
}