firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

Couldn't upload a buffer to firebase storage

Open EssaadaniYounes opened this issue 1 year ago • 6 comments

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

EssaadaniYounes avatar Mar 27 '24 02:03 EssaadaniYounes

code I hope this image describe the steps and what i did

EssaadaniYounes avatar Mar 27 '24 02:03 EssaadaniYounes

  1. What is the error message?
  2. You're mentioning you're using ExpressJS. Is this a Node project? Would it make more sense to use firebase-admin?

hsubox76 avatar Apr 12 '24 18:04 hsubox76

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!

google-oss-bot avatar Apr 19 '24 01:04 google-oss-bot

  1. What is the error message?
  2. 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

EssaadaniYounes avatar Apr 21 '24 18:04 EssaadaniYounes

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.

dlarocque avatar Apr 22 '24 22:04 dlarocque

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!

google-oss-bot avatar Apr 29 '24 01:04 google-oss-bot

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.

google-oss-bot avatar May 06 '24 01:05 google-oss-bot