Question

How to save a image from Node to DigitalOcean spaces?

Greetings, I have a backend in node.js for my Android App,the backend receive a encode base64 image, then write using “fs.writeFileSync” but i wanna change to save in DigitalOcean Space, there a way to do that?

PD: Sorry for me bad english


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Thanks, for now i am gonna save images in my DO droplet without DO spaces, that’s because are receive the images encoded in base64 and i dont found the way to pass to DO spaces

Try this, you should use the resized images content.

$image_resize = $image_resize->resize(50, 50, function ($constraint) { $constraint->aspectRatio(); })->encode(‘jpg’);

Storage::disk(‘spaces’)->put($thumb_uploads .‘/’.$image->hashName(), (string) $image_resize);

Hi @bytesve,

I’ll recommend giving the following Digitalocean tutorial a read :

https://www.digitalocean.com/community/tutorials/how-to-upload-a-file-to-object-storage-with-node-js

In this tutorial, you will create a Node.js application that allows a user to upload a file to their DigitalOcean Space by submitting a form on the front-end of a website. It should help you out in regards to your application as well.

Regards, KFSys