Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't upload a buffer to firebase storage #8103

Closed
EssaadaniYounes opened this issue Mar 27, 2024 · 7 comments
Closed

Couldn't upload a buffer to firebase storage #8103

EssaadaniYounes opened this issue Mar 27, 2024 · 7 comments

Comments

@EssaadaniYounes
Copy link

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 EssaadaniYounes added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Mar 27, 2024
@EssaadaniYounes
Copy link
Author

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

@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Mar 27, 2024
@hsubox76
Copy link
Contributor

  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?

@google-oss-bot
Copy link
Contributor

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!

@EssaadaniYounes
Copy link
Author

  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

@dlarocque
Copy link
Contributor

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.

@google-oss-bot
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants