( image: File, onProcessing?: (file: File) => void, )
| 1206 | export const uploadNotAcceptedMessage = `File type is not allowed or the size exceeded the limit of ${imageSizeLimitMB} MB`; |
| 1207 | |
| 1208 | export const uploadContentImage = async ( |
| 1209 | image: File, |
| 1210 | onProcessing?: (file: File) => void, |
| 1211 | ): Promise<string> => { |
| 1212 | if (image.size > allowedFileSize) { |
| 1213 | throw new Error(`File size exceeds the limit of ${imageSizeLimitMB} MB`); |
| 1214 | } |
| 1215 | |
| 1216 | if (!allowedContentImage.includes(image.type)) { |
| 1217 | throw new Error('File type is not allowed'); |
| 1218 | } |
| 1219 | |
| 1220 | if (onProcessing) { |
| 1221 | onProcessing(image); |
| 1222 | } |
| 1223 | |
| 1224 | const res = await gqlClient.request(UPLOAD_IMAGE_MUTATION, { image }); |
| 1225 | |
| 1226 | return res.uploadContentImage; |
| 1227 | }; |
| 1228 | |
| 1229 | export enum PostRelationType { |
| 1230 | Collection = 'COLLECTION', |
no outgoing calls
no test coverage detected