By tundeola
I kept on getting this error when I try to post image to my space using nodejs { “message”: null, “code”: “NoSuchBucket”, “region”: null, “time”: “2021-03-07T09:26:39.174Z”, “requestId”: “tx000000000000042b7e140-0060449c4f-2a11d50-nyc3c”, “statusCode”: 404, “retryable”: false, “retryDelay”: 25.85127983870934, “storageErrors”: [] } I added my bucket name from spaces but I don’t know why I kept on getting this error. Please help
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!
Hi @tundeola,
Spaces is inter-operable with the AWS S3 API allowing you to take advantage of the existing ecosystem of tools for it. Below is a basic example demonstrating how to upload a file using the AWS JavaScript SDK, you can install it with:
npm install aws-sdk
The key is to set the endpoint to point to Spaces:
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);
});
Can you try uploading the image that way and see if it would work properly?
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.