diff options
author | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-02 17:42:18 -0700 |
---|---|---|
committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-02 17:42:18 -0700 |
commit | fb329b1a8abca361d831c7ec1f1a9ea0f3d410cf (patch) | |
tree | e09138a0544fe3814b1bd1e95d59bc4c0e96f5ed /src/server/SharedMediaTypes.ts | |
parent | 3a1dac48c00dbe81142da90f8b52bfae02ce1921 (diff) | |
parent | b4958eac84339dd7a88c964a9c52e89481048f55 (diff) |
merge
Diffstat (limited to 'src/server/SharedMediaTypes.ts')
-rw-r--r-- | src/server/SharedMediaTypes.ts | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/server/SharedMediaTypes.ts b/src/server/SharedMediaTypes.ts index 8d0f441f0..2495123b7 100644 --- a/src/server/SharedMediaTypes.ts +++ b/src/server/SharedMediaTypes.ts @@ -1,8 +1,50 @@ +import { ExifData } from 'exif'; +import { File } from 'formidable'; + export namespace AcceptibleMedia { export const gifs = [".gif"]; export const pngs = [".png"]; export const jpgs = [".jpg", ".jpeg"]; - export const imageFormats = [...pngs, ...jpgs, ...gifs]; + export const webps = [".webp"]; + export const tiffs = [".tiff"]; + export const imageFormats = [...pngs, ...jpgs, ...gifs, ...webps, ...tiffs]; export const videoFormats = [".mov", ".mp4"]; export const applicationFormats = [".pdf"]; + export const audioFormats = [".wav", ".mp3", ".flac", ".au", ".aiff", ".m4a", ".webm"]; +} + +export namespace Upload { + + export function isImageInformation(uploadResponse: Upload.FileInformation): uploadResponse is Upload.ImageInformation { + return "nativeWidth" in uploadResponse; + } + + export interface FileInformation { + accessPaths: AccessPathInfo; + } + + export type FileResponse<T extends FileInformation = FileInformation> = { source: File, result: T | Error }; + + export type ImageInformation = FileInformation & InspectionResults; + + export interface AccessPathInfo { + [suffix: string]: { client: string, server: string }; + } + + export interface InspectionResults { + source: string; + requestable: string; + exifData: EnrichedExifData; + contentSize: number; + contentType: string; + nativeWidth: number; + nativeHeight: number; + filename?: string; + } + + export interface EnrichedExifData { + data: ExifData; + error?: string; + } + }
\ No newline at end of file |