How can I get in a call back after inserting a file using collectionFS the key value?
Images.insert(file, function (err, fileObj) {
if (err) {
console.log(err);
} else {
console.log('success', fileObj);
setTimeout(function () {
console.log('url', fileObj.url());
let url = fileObj.url('images');
$scope.slideshows.url = `${url}`
$scope.$apply();
}, 2000);
}
});
I'm building a cms which handles file uploads to show in different apps, I'm able to see the uploaded file using {{image.url}} in the cms but I'm unable to view the images uploaded using this method in the other apps.
Every app is connecting to the same database and I'm uploading the images into my server using:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: '/home/uploadedimages'})]
});
I'm then using nginx to serve those images so I can access them via http://domain.com/uploadedimages.
In order to fix my problem I need to somehow get the key value in this schema stored by collectionFS:
{
"_id" : "5BEe4maLCMFtHAZAj",
"original" : {
"name" : "wantedposter.jpg",
"updatedAt" : ISODate("2016-05-19T13:34:32.050Z"),
"size" : 28828,
"type" : "image/jpeg"
},
"uploadedAt" : ISODate("2016-05-19T21:30:54.299Z"),
"copies" : {
"images" : {
"name" : "wantedposter.jpg",
"type" : "image/jpeg",
"size" : 28828,
"key" : "images-5BEe4maLCMFtHAZAj-wantedposter.jpg",
"updatedAt" : ISODate("2016-05-19T21:30:54Z"),
"createdAt" : ISODate("2016-05-19T21:30:54Z")
}
}
}
So I can do /uploadedimages/:key
QUESTION
Is there a way to get the key value from collectionFS?