I'm using the LoopBack storage component to upload and download files to azure cloud storage as illustrated on their documentation
I've created model named container in model-config.json
"container": {
"dataSource": "storage",
"public": true
}
with datasource in datasouce.json
"storage": {
"name": "storage",
"connector": "loopback-component-storage",
"provider": 'azure',
"storageAccount": "xxxxx",
"storageAccessKey": "xxxx"
}
Now I've a REST API, as described in their documentation. here's the error I've got each time I call one of the generated GET /api/containers endpoint.
{
"error": {
"name": "Error",
"status": 400,
"message": "azure Error (400): Bad Request",
"provider": "azure",
"failCode": "Bad Request",
"statusCode": 400,
"href": "http://xxxx.blob.core.windows.net/?comp=list",
"method": "GET",
"headers": {
"content-type": "application/xml",
"server": "Microsoft-HTTPAPI/2.0",
"x-ms-request-id": "820995fc-0001-013e-7b9a-48de28000000",
"date": "Sun, 27 Nov 2016 10:40:02 GMT",
"cache-control": "proxy-revalidate",
"content-length": "328",
"connection": "close"
},
"result": {
"err": "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:820995fc-0001-013e-7b9a-48de28000000\nTime:2016-11-27T10:40:02.3522933Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>2011-08-18</HeaderValue></Error>"
}
}
}
after searching for this error I've found this answer my question is whether I have to set the header manually and how to do it or there's a missing configuration for azure storage for loopback-storage-component.
I added this piece of code to common/models/container.js and I get the same error.
module.exports = function(Container) {
Container.beforeRemote('**', function(context, user, next) {
//2015-12-11
context.res.set('x-ms-version', '2015-12-11');
next();
});
};