Uploading image from online link to supabase always returns application/octet-stream
See original GitHub issueI tried to upload a file from a URL to Supabase storage. I always get an object with application/octet-stream
mime type. It only happens on Cloudflare workers. I tried it on a normal server and it works well. Here is my code:
const { createClient } = require('@supabase/supabase-js')
const supabase = createClient('SUPABASE_URL', 'SUPABASE_ANON_KEY')
async function upload (url) {
const blob = await fetch(url)
.then(response => response.blob())
const fileName = 'test.' +blob.type.split('/')[1]
const result = await supabase
.storage
.from('avatars')
.upload(fileName, blob, {
cacheControl: '3600',
contentType: blob.type,
upsert: true,
})
console.log(result)
}
upload('https://tinypng.com/images/panda-happy-2x.png')
Issue Analytics
- State:
- Created a year ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
Storage: What is the public URL of the image? #1146 - GitHub
I don't know the public URL after uploading the image. ... base64.replace('data:application/octet-stream;base64' , "data:image/png;base64").
Read more >Why is my file type "application/octet-stream" when I upload ...
I am doing this through the web. When I download an image and upload it, the image type is set as "application/octet-stream" and...
Read more >How To Upload Files To Supabase Storage Buckets and Write ...
Overview. Simple application showing file upload and writing database records using Remix and Supabase. We show how Actions and Loaders work ...
Read more >Images put to storage are saved as 'octet-stream' rather than ...
Results: In Firebase (storage) The image is being saved as application/octet-stream instead of image/jpeg. The image is not shown, it says ...
Read more >Storage Image Transformations - Supabase
Transform images with Storage. ... This returns the public URL that serves the resized image. supabase.storage.from('bucket').getPublicUrl('image.jpg' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Did some digging, this is the code in
@supabase/supabase-js
that does the uploading: https://github.com/supabase/storage-js/blob/1a7d98c3e8f90c43ab7c7c2b52a34f99bb0736b7/src/lib/StorageFileApi.ts#L74-L76. Looks likeundici
’sFormData
class discardsBlob
type
s whenappend
ing toFormData
:See the corresponding
undici
code here: https://github.com/nodejs/undici/blob/4684a1543d87e98b441959d731a3a13d20eaa17d/lib/fetch/formdata.js#L244-L248. Probably worth an issue inundici
?A potential temporary solution though is to pass a non-
Blob
/File
type toupload
, triggering this code path instead: https://github.com/supabase/storage-js/blob/1a7d98c3e8f90c43ab7c7c2b52a34f99bb0736b7/src/lib/StorageFileApi.ts#L81-L83:Cool. In that case I am going to close this, since there is nothing to track here and you have provided a workaround.