JS SDK Upload method calls toString on data before uploading
ranile opened this issue · 0 comments
ranile commented
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.
GET request to download file (from chrome)
Response for request where the file is uploaded as Uint8Array
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