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

JS SDK Upload method calls toString on data before uploading #166

Open
2 tasks done
ranile opened this issue May 27, 2023 · 0 comments
Open
2 tasks done

JS SDK Upload method calls toString on data before uploading #166

ranile opened this issue May 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ranile
Copy link

ranile commented May 27, 2023

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

A clear and concise description of what the bug is.
When uploading to Supabase Storage, the JS SDK calls toString on data before uploading when the file is not a File or Uint8Array (there may be others, I have not tested it).

To Reproduce

const bytes = [0, 1, 2, 3]
// const bytes = new Uint8Array([0, 1, 2, 3]);
const { data, error } = await supabase.storage
    .from('attachments')
    .upload(`attachments/${id}`, bytes, {
        contentType: 'application/octet-stream'
    });

Comment out the first line and uncomment the second line and notice the difference in the files uploaded.

Expected behavior

If unexpected input is provided (such as an Array), the function should fail instead of uploading a string representation of the file.

Screenshots

Chrome console, logging the input passed to upload.
image

GET request to download file (from chrome)
image

Response of above request:
image

Response for request where the file is uploaded as Uint8Array
image

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

>> file 01H1FA0E1CGCTQKN0G2DZ09BX8
01H1FA0E1CGCTQKN0G2DZ09BX8: ASCII text, with no line terminators

>> file 01H1FAKQ7QS65CH4WVAAYGZAG1
01H1FAKQ7QS65CH4WVAAYGZAG1: data
@ranile ranile added the bug Something isn't working label May 27, 2023
ranile referenced this issue in ranile/firestorm May 27, 2023
I hate how much time supabase wasted, making me figure out that array is stringified before uploading: https://github.com/supabase/supabase-js/issues/780
@steve-chavez steve-chavez transferred this issue from supabase/supabase-js May 27, 2023
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

1 participant