lundi 4 mai 2015

Uploading Audio file to AWS S3 gives XML parse error

I'm trying to upload an audio file to S3 from my machine. I'm using a fake S3 service as to avoid using AWS resources whilst developing.

With the code pasted below I can successfully upload text, pdf and image files. However, when it comes to audio files (I've tried mp3 and mp4) it returns the error:

{ [XMLParserError: Unexpected close tag
Line: 11
Column: 9
Char: >]
  message: 'Unexpected close tag\nLine: 11\nColumn: 9\nChar: >',
  code: 'XMLParserError',
  time: Mon May 04 2015 16:16:16 GMT+0100 (BST),
  statusCode: 400,
  retryable: false,
  retryDelay: 30 }

Code used for the uploading:

require('spurious-aws-sdk-helper')()

const filename = process.argv[2];
const fs = require('fs');
const AWS = require("aws-sdk");

AWS.config.update({
  accessKeyId: "access",
  secretAccessKey: "secret",
  region: "eu-west-1",
  sslEnabled: false,
  s3ForcePathStyle: true
})

const s3 = new AWS.S3();

var params = {Bucket: 'bucket', Key: 'key', Body:     fs.createReadStream(filename)};
s3.upload(params, function(err, data) {
  console.log(err, data);
});

I've tried uploading the file in different manners such as a buffer, stream and a blob. It always returns this error message.




Aucun commentaire:

Enregistrer un commentaire