0

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.

1
  • You said it has a buffer. That is the file. In the supabase documentation, click the button that says "Upload file using ArrayBuffer from base64 file data". Commented Jan 24 at 23:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.