aws s3file upload使用aws-sdk nodejs

我试图从用户{angularjs前端}上传文件到aws s3桶,并parsing文件到nodejs api路由,但不断收到错误:“TypeError:无法读取未定义的属性”文件“..我能够从postman(铬扩展)上传文件通过发送文件的请求,但我不知道如何parsing文件从angular度到节点js。 下面是在做什么:

// NODEJS代码:

router.post('/user/upload', multipartMiddleware, function(req, res){ var file = req.files.file; var body = fs.createReadStream(file.path); var filename = 'post7/media.jpg'; var s3bucket3 = new AWS.S3(); s3bucket3.createBucket({Bucket: 'artistarc-user-post-media'}, function() { var data = {Bucket: 'artistarc-user-post-media', Key: filename, Body: body}; s3bucket3.putObject(data, function(err, data) { if (err) { console.log("Error uploading data: ", err); } else { console.log("Successfully uploaded data to Bucket"); } }); }); res.end('Uploaded'); }); 

// ANGULARJS控制器:

 myApp.controller('galleryController', ['$scope', 'Api', function($scope, Api){ console.log('galleryController'); $scope.file = []; $scope.uploadFile = function(){ Api.MediaUpload.save({}, $scope.file, function(){ console.log('uploaded'); }); } }]); 

// EJS温和

 <form> <button type="button" class="btn btn-default btn-trans btn-sm" ng-click = "uploadFile()"> <span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span> Upload </button> <input type = "file" name = "file" ng-model="file" file/></div> </form> 

****我也试过使用指令,但也导致错误。 这是我所尝试的**

//指令'文件'

 myApp.directive('file', ['$scope', function($scope){ return { restrict: 'E', scope: { file: '@' }, link: function(scope, el, attrs){ el.bind('change', function(event){ var files = event.target.files; var file = files[0]; scope.file = file; scope.$parent.file = file; scope.$apply(); }); } }; }]);