Skip to content

error while accessing aws s3 bucketΒ #7282

@quant-daddy

Description

@quant-daddy
  • v6.2.0:
  • Linux surajPC 4.2.0-36-generic rename node.js -> io.jsΒ #42~14.04.1-Ubuntu SMP Fri May 13 17:27:22 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux:
  • Subsystem:

I'm using the code below

//this code in fileA.js
var aws = require('aws-sdk'),
  http = require('http'),
  fs = require('fs'),
  path = require('path'),
  express = require('express');

var app = new express();

var config_path = path.join(__dirname, '../auth.json');

aws.config.loadFromPath(config_path);
var s3 = new aws.S3();

app.get('/buckets', function (req, res) {
  s3.listBuckets(function (err, data) {
    res.json(data);
  });
});

module.exports = app;

//Then I call this module in another file
var app = require('./fileA'),
  http = require('http');

http.createServer(app).listen(3000, function(){
  console.log('Server listening on port 3000');
});

Once I access the localhost:3000/buckets, I get the following error:

TypeError: Cannot read property 'length' of null
    at Object.AWS.util.buffer.concat (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/util.js:116:29)
    at Request.HTTP_DONE (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/event_listeners.js:214:36)
    at Request.callListeners (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/sequential_executor.js:132:20)
    at Request.emit (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/sequential_executor.js:100:10)
    at Request.emitEvent (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/request.js:408:10)
    at IncomingMessage.onEnd (/home/suraj/Desktop/server/node_modules/aws-sdk/lib/event_listeners.js:184:26)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)

I'm not sure if this has anything to do with the warning I get when I npm install aws -sdk

npm WARN amazons3@0.0.0 No repository field.
npm WARN amazons3@0.0.0 license should be a valid SPDX license expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions