Corrupted File on upload
Hi! I am using supabase-js
I am facing an issue where every upload that I did contains this in the file header When uploading via the dashboard, the file uploads fine. When uploading via the JS SDK, the header get inserted to every file happens. Here are my code snippets I did have a browse through the issue tracker(https://github.com/supabase/supabase/issues/36929) and this seems related? Anyone facing the same issue?
I am facing an issue where every upload that I did contains this in the file header When uploading via the dashboard, the file uploads fine. When uploading via the JS SDK, the header get inserted to every file happens. Here are my code snippets I did have a browse through the issue tracker(https://github.com/supabase/supabase/issues/36929) and this seems related? Anyone facing the same issue?
GitHub
[Bug] Storage in sa-east-1: Successful PNG uploads are being served...
Bug report Hello, I'm experiencing a critical bug with Supabase Storage in my project. Project Ref: gnmxihdaawlenwspsxum Region: sa-east-1 Problem: When I upload a valid PNG file (e.g., ~745KB)...
29 Replies
Is this React Native?
It's nextjs
Not enough info from that user's issue as they don't even say how they are uploading.
No other reports I've seen.
The storage UI does use the REST API, so seems something about your method.
Is it one particular file?
Does the corrupted file have a length?
It's every file that's uploaded via the SDK. I did a console log before uploading and the file looks fine. The length of the file is the same when I look via network inspector
I see this header when I upload...

I will test it via the kotlin SDK and REST API. I might be able to replicate this issue
2.50.3 supabase-js
What happens when you download the file via the dashboard?
It is fine.
There is no general issue with storage or there would be lots of reports.
And if you can upload with UI then not likely your instance.
You are using .name for an extension?
Is the mimetype being set in your fileobject to .txt?
I'm not sure the contentType overrides what is in the blob or extension of the filename for a blob upload.
This reads like it is not.

What does the storage UI say the mime type is?

I'm using txt as my extension.
${file.name} expands to testfile.txt
The storage UI says the mime type is application/json
Oh sorry, just glanced.
How are you getting the file into the blob object?
https://developer.mozilla.org/en-US/docs/Web/API/File/name
I'm getting the file via input
And what type is it?
What is file.name when you log it out?
Are you uploading from the browser in a browser client (versus a server component)?
I don't use next.js, so may not make sense.
console.log shows testfile.txt. I am uploading via browser
<input
type="file"
hidden
id="browse"
ref={fileInputRef}
onChange={handleFileChange}
multiple={false}
/>
When I upload txt file from dashboard, the mime type is
text/plain
. When uploading file, you can try setting mime type yourself
mime type is also available on the File object. file.type
this is the content of the file when uploaded

Did you set mimetype when uploading?

It says it defaults to text/plain but still
I shouldn't have to manually set the content type but I did it anyway
the network inspector shows this

@LittleCat I thought you were seeing this on upload?
Which does seem to have an issue. Your last image seems correct.

This is my code and upload works fine

yeah. it's an issue with my code. this simple code works out of the box. I will have to do some digging
thank you for your help. I found the bug
The issue is that I added global headers to my createClient code. Removing the
Content-Type
header will upload my file successfully in the correct mime type.Crap. That is a first. So it replaces whatever storage comes up with.
Why are you setting any of those though?
apikey is set by Supabase.
Accept should also be set properly.
😳 I was vibe coding for a bit since this is boilerplate code