Couldn't upload a buffer to firebase storage
Operating System
Window 10
Browser Version
Chrome
Firebase SDK Version
10.7.2
Firebase SDK Product:
Storage
Describe your project's tooling
ExpressJS with typescript and sharp
Describe the problem
I'm having a task as follow
- You give the API a image URL you get this image URL data as ArrayBuffer using axios
- Take the ArrayBuffer and pass it to sharp to resize the image
- Store the result from sharp (a Buffer ) in firebase storage
Steps and code to reproduce issue
#Upload buffer to firebase storage
I hope this image describe the steps and what i did
- What is the error message?
- You're mentioning you're using ExpressJS. Is this a Node project? Would it make more sense to use
firebase-admin?
Hey @EssaadaniYounes. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
- What is the error message?
- You're mentioning you're using ExpressJS. Is this a Node project? Would it make more sense to use
firebase-admin?
The error is when I'm visiting firebase storage and i click on the image to preview it i got no preview available instead of actual image.
And yeah it's a node project and the same issue with firebase admin
Hi @EssaadaniYounes
Could you try modifying your sharp code to be:
const sharped = await sharp(image)
.raw()
.ensureAlpha()
.resize(size.width, size.height, { fit: "inside" })
.jpeg() // Write it in jpeg format https://sharp.pixelplumbing.com/api-output#jpeg
.toBuffer({ resolveWithObject: true });
I have reproduced your error locally, and found the same preview error you encountered. Adding the jpeg() call fixed the issue for me.
If you are still having issues viewing the preview, try writing the file to disk with toFile(), and make sure you can open that locally. If you are able to open it locally, and it still fails to preview in storage, please send us the code as well as the image.
Hey @EssaadaniYounes. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@EssaadaniYounes if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.