aboutsummaryrefslogtreecommitdiff
path: root/src/server/SharedMediaTypes.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2020-02-16 00:50:23 -0500
committerSam Wilkins <samwilkins333@gmail.com>2020-02-16 00:50:23 -0500
commitf33ad290f1de3a01f2c4536f03f040e09771f82e (patch)
treee69ccddbfe5d7bacd70d30483903084e5fed2a3e /src/server/SharedMediaTypes.ts
parent03b33592cf7f244094bb594c8251ab9c3e0ee48f (diff)
improved file upload api
Diffstat (limited to 'src/server/SharedMediaTypes.ts')
-rw-r--r--src/server/SharedMediaTypes.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/server/SharedMediaTypes.ts b/src/server/SharedMediaTypes.ts
index 274b4f01e..185e787cc 100644
--- a/src/server/SharedMediaTypes.ts
+++ b/src/server/SharedMediaTypes.ts
@@ -1,3 +1,6 @@
+import { ExifData } from 'exif';
+import { File } from 'formidable';
+
export namespace AcceptibleMedia {
export const gifs = [".gif"];
export const pngs = [".png"];
@@ -7,4 +10,40 @@ export namespace AcceptibleMedia {
export const imageFormats = [...pngs, ...jpgs, ...gifs, ...webps, ...tiffs];
export const videoFormats = [".mov", ".mp4"];
export const applicationFormats = [".pdf"];
+}
+
+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