Question

Issue completing basic commands for Spaces using s3 AWS SDK on NodeJS

Using the docs here, I attempted to get a list of available spaces. However, I get the following error:

NotImplemented: Server does not support one or more requested headers. Please see https://de
velopers.digitalocean.com/documentation/spaces/#aws-s3-compatibility                       
    at Request.extractError (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/li
b/services/s3.js:837:35)                                                                   
    at Request.callListeners (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/l
ib/sequential_executor.js:106:20)                                                          
    at Request.emit (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib/sequen
tial_executor.js:78:10)                                                                    
    at Request.emit (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib/reques
t.js:688:14)                                                                               
    at Request.transition (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib/
request.js:22:10)                                                                          
    at AcceptorStateMachine.runTo (/home/vincent/workspace/tuts-express-js/node_modules/aws-
sdk/lib/state_machine.js:14:12)                                                            
    at /home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib/state_machine.js:26:
10                                                                                         
    at Request.<anonymous> (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib
/request.js:38:9)                                                                          
    at Request.<anonymous> (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/lib
/request.js:690:12)                                                                        
    at Request.callListeners (/home/vincent/workspace/tuts-express-js/node_modules/aws-sdk/l
ib/sequential_executor.js:116:18) {                                                        
  code: 'NotImplemented',
  region: null,
  time: 2020-07-27T15:42:27.398Z,
  requestId: null,
  extendedRequestId: undefined,
  cfId: undefined,
  statusCode: 501,
  retryable: true

Code is below:

const AWS = require("aws-sdk");

// set to use the digital ocean s3
AWS.config.credentials = new AWS.SharedIniFileCredentials({
  profile: "digitalocean"
});

// configure endpoints for DO spaces
const spacesEndpoint = new AWS.Endpoint("nyc3.digitaloceanspaces.com");
const s3 = new AWS.S3({
  endpoint: spacesEndpoint
});

// list buckets
s3.listBuckets({}, function(err, data) {
  if (err) console.log(err, err.stack);
  else {
    data["Buckets"].forEach(function(space) {
      console.log(space["Name"]);
    });
  }
});

// list the available buckets
s3.listObjects({ Bucket: "my-experimental-expressjs-piece" }, function(
  err,
  data
) {
  if (err) {
    console.log(err);
  } else {
    console.log(data);
  }
});

Any idea what might be going wrong?


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