A
A
Alexey Dugnist2016-02-04 13:07:28
JavaScript
Alexey Dugnist, 2016-02-04 13:07:28

TypeError: Not a buffer - how to resolve this error?

I'm trying to upload a file to amazon using aws.

AWS.config.credentials = new AWS.Credentials(
      options.accessKeyId,
      options.secretAccessKey,
      null
)

this.s3 = new AWS.S3()

var fileBuff = new Buffer( file )

this.s3.upload( {
      Bucket: this.getBucket(obj),
      Key: obj.name+'.txt',
      Body: fileBuff })
        .on( 'httpUploadProgress', function(evt) { console.log(evt) })
        .send( function(err, data) {
          console.log( err )
          console.log( data )
          callback( err, data )
        })

Throws an error "{ [TypeError: Not a buffer] retryDelay: 30 }"
Has anyone encountered this problem?
PS
console.log( fileBuff )
gives away:
<Buffer 74 65 78 74>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dugnist, 2016-02-04
@Peekab0o

The problem was in the AWS.config.credentials settings. The solution is mindfulness...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question