admin管理员组

文章数量:1190758

I can't get image files be properly uploaded to Supabase, because I do not know how to parse request object so that I would have the right value. this is what docs say:

For React Native, using either Blob, File or FormData does not work as intended. Upload file using ArrayBuffer from base64 file data instead, see example below.
export const tryUploadUserProfileImage = async (
  file: formidable.File, // does not work
  user: CreateUserPayload 
) => {
  const { data, error } = await supabase.storage
    .from("images")
    .upload(`public/${user.name}/${file.originalFilename}`, file, {
      contentType: file.mimetype!,
      upsert: true,
    });

  if (error) {
    logger.error("Failed to upload profile image", error);
    return;
  }
  return data.fullPath;
};

Tried to use multer it had Express.Multer.File on req.file, which only had buffer. Also same goes for fs. Formidable does not work.

本文标签: expressHow to parse request object that contains FormData to get FileBlobStack Overflow