-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
500 errors when uploading to supabase bucket with blob data type with supabase-js #163
Comments
I am also having this issue |
Seems to be a problem with a missing column in the storage.objects table:
Full error log here: Adding the column (which seems to be only missing in the local version of my project) fixes the issue. I used the following SQL: alter table "storage"."objects" add column "version" text; |
My apologies. Looking at the initial message again makes me think that this is probably totally unrelated. 😄 |
I was getting the same error, and later I decided to try Base64 instead of Blob. This solved my problem, and it might solve yours too. Imports: import { supabase } from "../../../libs/supabase";
import * as ImagePicker from "expo-image-picker";
import * as FileSystem from "expo-file-system";
import { decode } from "base64-arraybuffer"; Pick Image: const pickImage = async () => {
const options: ImagePicker.ImagePickerOptions = {
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
};
const result = await ImagePicker.launchImageLibraryAsync(options);
if (!result.canceled) {
const img = result.assets[0];
const base64 = await FileSystem.readAsStringAsync(img.uri, {
encoding: "base64",
});
const filePath = `${id}/avatar_${new Date().getTime()}.jpg`;
const contentType = "image/jpeg";
const { error } = await supabase.storage
.from("avatars")
.upload(filePath, decode(base64), { contentType, upsert: true });
if (error) throw error;
updatePhoto(filePath);
}
}; Update Photo: const updatePhoto = async (filePath: string) => {
const {
data: { publicUrl },
} = supabase.storage.from("avatars").getPublicUrl(filePath);
setImage(publicUrl);
const { error } = await supabase.auth.updateUser({
data: { avatar_url: publicUrl },
});
if (error) throw error;
}; |
I have same error:
|
In my case, my insert and update storage policies were breaking from a change I had made to one of the fields the policies relied on. |
@otopba Were you able to get this working? I am facing the same exact error, which is not too helpful in being able to solve the issue. |
Bug report
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 parameterERROR 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 insteadTo Reproduce
this code uses expo image picker
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
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: