MCPcopy Create free account
hub / github.com/dailydotdev/apps / uploadContentImage

Function uploadContentImage

packages/shared/src/graphql/posts.ts:1177–1196  ·  view source on GitHub ↗
(
  image: File,
  onProcessing?: (file: File) => void,
)

Source from the content-addressed store, hash-verified

1175export const uploadNotAcceptedMessage = `File type is not allowed or the size exceeded the limit of ${imageSizeLimitMB} MB`;
1176
1177export const uploadContentImage = async (
1178 image: File,
1179 onProcessing?: (file: File) => void,
1180): Promise<string> => {
1181 if (image.size > allowedFileSize) {
1182 throw new Error(`File size exceeds the limit of ${imageSizeLimitMB} MB`);
1183 }
1184
1185 if (!allowedContentImage.includes(image.type)) {
1186 throw new Error('File type is not allowed');
1187 }
1188
1189 if (onProcessing) {
1190 onProcessing(image);
1191 }
1192
1193 const res = await gqlClient.request(UPLOAD_IMAGE_MUTATION, { image });
1194
1195 return res.uploadContentImage;
1196};
1197
1198export enum PostRelationType {
1199 Collection = 'COLLECTION',

Callers 5

FeedbackModalFunction · 0.90
handleSubmitFunction · 0.90
onScreenshotSelectFunction · 0.90
handleIconBase64Function · 0.90
uploadImageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected