Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | import { handleImageFromFormData } from '@api/facade/handleImageFromFormData'; import { FormDataKey } from '@constants/form'; import { BioMediaImageSize, DefaultImageRestrictions } from '@constants/image'; import { IDatabaseFile } from '@contracts/databaseFile'; import { IFormWithFiles } from '@contracts/file'; import { ResultWithValue } from '@contracts/resultWithValue'; import { makeArrayOrDefault } from '@helpers/arrayHelper'; export interface IPlanetBuildImages { mediaFiles?: Array<IDatabaseFile>; } export const planetBuildFileHandler = async ( formData: IFormWithFiles, ): Promise<ResultWithValue<IPlanetBuildImages>> => { const result: IPlanetBuildImages = { mediaFiles: [], }; const mediaFilesFromForm = formData[FormDataKey.mediaFiles]; if (result.mediaFiles == null) result.mediaFiles = []; for (const mediaFileFromForm of makeArrayOrDefault(mediaFilesFromForm)) { const mediaFileResult = await handleImageFromFormData({ fileFromForm: mediaFileFromForm, restrictions: DefaultImageRestrictions.bioMediaPic, fileName: 'mediaPic', handlerName: 'planetBuildFileHandler', ...BioMediaImageSize, }); if (mediaFileResult.isSuccess == false) { continue; } result.mediaFiles.push(mediaFileResult.value); } return { isSuccess: true, value: result, errorMessage: '', }; }; |