1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import { ExifData } from 'exif';
import { File } from 'formidable';
export namespace AcceptableMedia {
export const gifs = ['.gif'];
export const pngs = ['.png'];
export const jpgs = ['.jpg', '.jpeg'];
export const webps = ['.webp'];
export const tiffs = ['.tiff'];
export const imageFormats = [...pngs, ...jpgs, ...gifs, ...webps, ...tiffs];
export const videoFormats = ['.mov', '.mp4', '.quicktime', '.mkv', '.x-matroska;codecs=avc1'];
export const applicationFormats = ['.pdf'];
export const audioFormats = ['.wav', '.mp3', '.mpeg', '.flac', '.au', '.aiff', '.m4a', '.webm'];
}
export enum AudioAnnoState {
stopped = 'stopped',
playing = 'playing',
}
export namespace Upload {
export function isImageInformation(uploadResponse: Upload.FileInformation): uploadResponse is Upload.ImageInformation {
return 'nativeWidth' in uploadResponse;
}
export function isVideoInformation(uploadResponse: Upload.FileInformation): uploadResponse is Upload.VideoInformation {
return 'duration' in uploadResponse;
}
export interface AccessPathInfo {
[suffix: string]: { client: string; server: string };
}
export interface FileInformation {
accessPaths: AccessPathInfo;
rawText?: string;
duration?: number;
}
export interface EnrichedExifData {
data: ExifData & ExifData['gps'];
error?: string;
}
export interface InspectionResults {
source: string;
requestable: string;
exifData: EnrichedExifData;
contentSize: number;
contentType: string;
nativeWidth: number;
nativeHeight: number;
filename?: string;
}
export interface VideoResults {
duration: number;
}
export type FileResponse<T extends FileInformation = FileInformation> = { source: File; result: T | Error };
export type ImageInformation = FileInformation & InspectionResults;
export type VideoInformation = FileInformation & VideoResults;
}
|