Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/uploads/uploads.js
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | ): Promise<MultimediaUploadResult> { | ||||
const inputMimeType = | const inputMimeType = | ||||
files.length === 1 && body.mimeType ? body.mimeType : null; | files.length === 1 && body.mimeType ? body.mimeType : null; | ||||
if (inputMimeType && typeof inputMimeType !== 'string') { | if (inputMimeType && typeof inputMimeType !== 'string') { | ||||
throw new ServerError('invalid_parameters'); | throw new ServerError('invalid_parameters'); | ||||
} | } | ||||
const validationResults = await Promise.all( | const validationResults = await Promise.all( | ||||
files.map(({ buffer, size, originalname }) => | files.map(({ buffer, size, originalname }) => | ||||
validateAndConvert( | validateAndConvert({ | ||||
buffer, | initialBuffer: buffer, | ||||
overrideFilename ? overrideFilename : originalname, | initialName: overrideFilename ? overrideFilename : originalname, | ||||
inputDimensions, | inputDimensions, | ||||
inputLoop, | inputLoop, | ||||
inputEncryptionKey, | |||||
inputMimeType, | |||||
size, | size, | ||||
), | }), | ||||
), | ), | ||||
); | ); | ||||
const uploadInfos = validationResults.filter(Boolean); | const uploadInfos = validationResults.filter(Boolean); | ||||
if (uploadInfos.length === 0) { | if (uploadInfos.length === 0) { | ||||
throw new ServerError('invalid_parameters'); | throw new ServerError('invalid_parameters'); | ||||
} | } | ||||
const results = await createUploads(viewer, uploadInfos); | const results = await createUploads(viewer, uploadInfos); | ||||
return { results }; | return { results }; | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |