0

I have been working on getting a node file to be able to handle uploads to an S3 bucket. So far I have been able to get it to create a bucket, but when I run a post request with postman, I cannot seem to upload the file. I have removed the accessKeyId and secret accessKey. Any luck doing this before?

var S3FS = require("s3fs");
var s3fsImpl = new S3FS('TestBucket12345', {
            accessKeyId:"XXXXXXXXXXXXXXXXXXXXXXX", 
            secretAccessKey:"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
});


s3fsImpl.create();

var multiparty = require("connect-multiparty"),
    multipartyMiddleware = multiparty;
module.exports = function(router, passport){
    router.use(multipartyMiddleware);

  router.post('/fileupload', function(req, res){
        var file = req.files.file;
        var stream = fs.createReadStream(file.path);
        return s3fsImpl.writeFile(file.originalFilename, stream).then(function(){
            fs.unlink(file.path, function(err){
                if(err){
                console.log(err);
                }
            });
        });
    });
OrionHazHax
  • 1
  • 1
  • 1

0 Answers0