Skip to content
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

Can't upload metadata when uploading a file #195

Open
shaaandi opened this issue Mar 12, 2024 · 2 comments
Open

Can't upload metadata when uploading a file #195

shaaandi opened this issue Mar 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@shaaandi
Copy link

Trying to upload some meta-data along with uploading the file and it's not working.

I am doing this

supabase.storage.from('bucket-name').upload('some-file-anme', file, {
  metadata: { ...some data }
})

I have also tried

    const fileBody = new FormData();
    fileBody.append('metadata', JSON.stringify({ name: 'data' }));
    fileBody.append('', file);
    supabase.storage.from('bucket-name').upload('some-file-anme', fileBody )

I see that it doesn't support any metadata type so please let me know how to add a metadata while uploading the file.
I need the metadata for some RLS policies later.

Thanks alot.

@shaaandi shaaandi added the bug Something isn't working label Mar 12, 2024
@dan-hale
Copy link

I'm having a similar issue, but as long as I append the metadata before the file body the upload works as expected. Your second snippet actually solved this for me. I'm still not able to make the upload argument metadata object work at all.

image
Inspecting the request, both metadata objects look oddly identical (you can see them both) but if I remove the custom fileBody append prior to file content, supabase does not seem to save the metadata in the DB.

I tested using fileBody append, but placing the metadata first, resulting in no saved metadata to DB.

Something probably needs to be repaired on Supabase's ingestion servers to be able to handle the metadata coming after the body.

@rkristelijn
Copy link

It seems storing metadata kind of works with the @supabase/[email protected], but only for smaller files (<45kb), but with larger files it doesn't store (you need to look into a different schema (storage) , table objects. Also there doesn't seem to be a way to get the data back out api call .info() doesn't return anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants