Report this

What is the reason for this report?

How to save a image from Node to DigitalOcean spaces?

Posted on October 12, 2020

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



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!

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.

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

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);

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.