I heard you guys only support v2 for putObject signed urls. Which node.js clients should I use to create a signed url so I can upload files on the browser?
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!
@vallelungabrian here’s a tutorial recently published on the topic: https://www.digitalocean.com/community/tutorials/how-to-upload-a-file-to-object-storage-with-node-js
Support for v4 pre-signed URLs is in the works, but you can use v2 signatures with the AWS SDK as well. Depending on the version of the SDK you have installed, it maybe in use by default. (The latest version should when using a custom endpoint. Some older versions used v4 by default everywhere, but this change was reverted in version 2.152.0)
If needed, you can force the signature version when configuring your client:
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: 'YOURACCESSKEY',
secretAccessKey: 'YOURSECRETKEY',
signatureVersion: 'v2'
});
Here’s a quick example for generating a pre-signed putObject URL with a v2 signature:
const AWS = require('aws-sdk')
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: 'YOURACCESSKEY',
secretAccessKey: 'YOURSECRETKEY',
signatureVersion: 'v2'
});
var space = 'my-space-name'
var key = 'my-file-name'
var expireSeconds = 60
s3.getSignedUrl('putObject', {
Bucket: space,
Expires: expireSeconds,
Key: key
}, function (err, url) {
console.log(url);
});
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.