Skip to content

500 errors when uploading to supabase bucket with blob data type with supabase-js #163

Open
@migui3230

Description

@migui3230

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

supabase-js API for uploading to a bucket returns this error when trying to pass in a blob data type with the filename parameter
ERROR Error uploading image to bucket: {"error": "Internal", "message": "Internal Server Error", "statusCode": "500"}

it uploads perfectly when I started passing in an arrayBuffer data type instead

To Reproduce

this code uses expo image picker

const addPictureToTableAndBucket = async () => {
    const { data: session } = await supabase.auth.getSession();
    const user = session?.session?.user;
    const userId = user?.id;

    const fileExt = profileImage?.split(".").pop();
    const blob = await (await fetch(profileImage as string)).blob();

    const { data, error } = await supabase.storage
      .from("profile_pics")
      .upload(`${userId}.${fileExt}`, blob, {
        upsert: true,
      });

  };

  const pickImage = async () => {
    const result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    console.log(result);

    if (!result.canceled) {
      setProfileImage(result.assets[0].uri);
      await addPictureToTableAndBucket();
    }
  };

policies for the bucket are public and public for the insert, update, read, delete operations

Expected behavior

uploads happen perfectly for the bucket without any errors

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS Ventura 13.2
  • Version of supabase-js: 2.8.0
  • Version of Node.js: 19.5.0

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstorage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions