Hey. Anybody can tell, how to get the file name and simply insert it into the src? I read the documentation and I'm probably doing something wrong. Because in the collection, I see a lot of things, but I don't see the original file name.
PhotosCollection.load(photoLink, {
fileName: `${id}.png`,
});
but it did not help, files are still named differently.
PhotosCollection = new FilesCollection({
storagePath: process.env.PWD + '/public/photos',
downloadRoute: '/public/photos',
collectionName: 'photos',
allowClientCode: false,
cacheControl: 'public, max-age=31536000',
onBeforeUpload(file) {
if (file.size <= 20971520 && /png|jpg|jpeg/i.test(file.ext)) {
return true;
} else {
return 'Please upload image, with size equal or less than 20MB';
}
},
downloadCallback(fileObj) {
if (this.params.query.download == 'true') {
// Increment downloads counter
PhotosCollection.update(fileObj._id, {$inc: {'meta.downloads': 1}});
}
return true;
}
});
I just want to get an array of names of files and display them on the client, it is possible even without a path. I write them by myself ;)