Can I upload images to Spaces using node.js | DigitalOcean

PHOTO EMBED

Sat Aug 08 2020 04:44:29 GMT+0000 (Coordinated Universal Time)

Saved by @rdemo

const AWS = require('aws-sdk')

// Configure client for use with Spaces
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new AWS.S3({
    endpoint: spacesEndpoint,
    accessKeyId: 'ACCESS_KEY',
    secretAccessKey: 'SECRET_KEY'
});

// Add a file to a Space
var params = {
    Body: "The contents of the file",
    Bucket: "my-new-space-with-a-unique-name",
    Key: "file.ext",
};

s3.putObject(params, function(err, data) {
    if (err) console.log(err, err.stack);
    else     console.log(data);
});
content_copyCOPY

https://www.digitalocean.com/community/questions/can-i-upload-images-to-spaces-using-node-js