Changeset View
Changeset View
Standalone View
Standalone View
lib/actions/upload-actions.js
Show All 11 Lines | |||||
export type MultimediaUploadCallbacks = Shape<{ | export type MultimediaUploadCallbacks = Shape<{ | ||||
onProgress: (percent: number) => void, | onProgress: (percent: number) => void, | ||||
abortHandler: (abort: () => void) => void, | abortHandler: (abort: () => void) => void, | ||||
uploadBlob: UploadBlob, | uploadBlob: UploadBlob, | ||||
}>; | }>; | ||||
export type MultimediaUploadExtras = Shape<{ | export type MultimediaUploadExtras = Shape<{ | ||||
...Dimensions, | ...Dimensions, | ||||
loop: boolean, | loop: boolean, | ||||
encryptionKey?: string, | encryptionKey: string, | ||||
thumbHash: ?string, | |||||
}>; | }>; | ||||
const uploadMediaMetadata = | const uploadMediaMetadata = | ||||
( | ( | ||||
callServerEndpoint: CallServerEndpoint, | callServerEndpoint: CallServerEndpoint, | ||||
): ((input: UploadMediaMetadataRequest) => Promise<UploadMultimediaResult>) => | ): ((input: UploadMediaMetadataRequest) => Promise<UploadMultimediaResult>) => | ||||
async input => { | async input => { | ||||
const response = await callServerEndpoint('upload_media_metadata', input); | const response = await callServerEndpoint('upload_media_metadata', input); | ||||
Show All 27 Lines | if (extras.width !== null && extras.width !== undefined) { | ||||
stringExtras.width = extras.width.toString(); | stringExtras.width = extras.width.toString(); | ||||
} | } | ||||
if (extras.loop) { | if (extras.loop) { | ||||
stringExtras.loop = '1'; | stringExtras.loop = '1'; | ||||
} | } | ||||
if (extras.encryptionKey) { | if (extras.encryptionKey) { | ||||
stringExtras.encryptionKey = extras.encryptionKey; | stringExtras.encryptionKey = extras.encryptionKey; | ||||
} | } | ||||
if (extras.thumbHash) { | |||||
stringExtras.thumbHash = extras.thumbHash; | |||||
} | |||||
// also pass MIME type if available | // also pass MIME type if available | ||||
if (multimedia.type && typeof multimedia.type === 'string') { | if (multimedia.type && typeof multimedia.type === 'string') { | ||||
stringExtras.mimeType = multimedia.type; | stringExtras.mimeType = multimedia.type; | ||||
} | } | ||||
const response = await callServerEndpoint( | const response = await callServerEndpoint( | ||||
'upload_multimedia', | 'upload_multimedia', | ||||
Show All 35 Lines |