Trying to upload multiple image files to AWS
using loopback-component-storage
Here are the methods :
Game.add = function(ctx,options,cb)
{
var status = ctx.req.query.status,
defaultLangCode = ctx.req.query.defaultLangCode,
nameEn = ctx.req.query.nameEn;
var rec = new Object();
rec.parentHouseId = houseId;
rec.status = status;
rec.defaultLangCode = defaultLangCode;
rec.nameEn = nameEn;
if(!options) options = {forceIframeTransport : true};
ctx.req.params.container = 'common';
Game.app.models.container.upload(ctx.req,ctx.result,options,function (err,fileObj) {
if(err) {
cb(err);
} else {
var fileInfo = fileObj.files.file[0];
console.log(fileInfo);
}
});
};
AND
Game.remoteMethod(
'add',
{
http:{path: '/add', verb: 'post', status: 200, errorStatus: 400},
accepts: [
{ arg: 'ctx', type: 'object', http: { source:'context' } },
{ arg: 'options', type: 'object', http:{ source: 'query'} }
],
returns: {
arg: 'fileObject', type: 'object', root: true
}
}
);
I am trying to upload two image files there. Posting data/image produces this error twice:
Failed to create a multipart upload on S3: {"message":"Access Denied","stack":"AccessDenied: Access Denied\n at Request.extractError (/vagrant/node_modules/aws-sdk/lib/services/s3.js:538:35)\n at Request.callListeners (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:105:20)\n
at Request.emit (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:77:10)\n
at Request.emit (/vagrant/node_modules/aws-sdk/lib/request.js:668:14)\n at Request.transition (/vagrant/node_modules/aws-sdk/lib/request.js:22:10)\n at AcceptorStateMachine.runTo (/vagrant/node_modules/aws-sdk/lib/state_machine.js:14:12)\n at /vagrant/node_modules/aws-sdk/lib/state_machine.js:26:10\n at Request. (/vagrant/node_modules/aws-sdk/lib/request.js:38:9)\n at Request. (/vagrant/node_modules/aws-sdk/lib/request.js:670:12)\n at Request.callListeners (/vagrant/node_modules/aws-sdk/lib/sequential_executor.js:115:18)","code":"AccessDenied","region":null,"time":"2016-08-24T19:43:28.415Z","requestId":"2802978376D53185","extendedRequestId":"LhRlXP6H2EQo8M0ECUlL8js4W9CP99h5fvsSHjVSs3mhB9OupvWpz7UdB1HhN0Ntxf6sFLYoHdk=","statusCode":403,"retryable":false,"retryDelay":44.73750370088965}
Second one is of-course different.
I tried using empty options
object without luck.
Any kind of advice is welcome. Thanks in advance.
Tried working with different key/key id , same result. And how do I get the uploaded file's url? That of-course after I can successfully upload images :p