Hi,
Files aren't stored directly with Kinvey (they're on Google Cloud Storage). That's why accessing them is a little different compared to the data in collections.
Regards,
Wani
Hey,
thanks for your reply - strange that it isn't available like a find or insert?
Best, Nico
Hi Nico,
Apologies for the late reply.
Please refer to the code below
var context = modules.backendContext; var utils = modules.utils; var appKey = context.getAppKey(); var masterSecret = context.getMasterSecret(); var uri = 'https://' + request.headers.host + '/blob/'+ appKey + '/' + doc.avatar._id; // id variable var authString = "Basic " + utils.base64.encode(appKey + ":" + masterSecret); var requestOptions = { uri:uri, headers: { "Authorization":authString } }; var auth = modules.request.get(requestOptions,function(error, res, body){ if (error){ response.error(error); } else { response.body = JSON.parse(body); response.complete(res.status); } });
I have tested this in BL. This should work with your doc.avatar._id value.
I am checking if there is a simpler way to do this. I will get back to you on that.
Regards,
Wani
Nico Barelmann
Hey,
i want to build some logic regarding files inside my business logic - how can i find an file.object inside bl ?
modules.collectionAccess.collection('files').find({'_id' : doc.avatar._id}, {}, function(err, file){
...
Doesn't seem to work. What's wrong?