veliovgroup / Meteor-Files

🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.
https://packosphere.com/ostrio/files
BSD 3-Clause "New" or "Revised" License
1.11k stars 166 forks source link

FilesCollection.find(...).each() not working properly? #876

Closed Gobliins closed 1 year ago

Gobliins commented 1 year ago

I'm having a strange beahviour with the FilesCollection().find().each() function:

const files = FilesCollection.find({'_id': { $in: fileIds } }).fetch();
files[0].link() // no function link

Getting some files but they can't generate the url with the link() function.

When i use FilesCollection.findOne({'_id': fileId } }) I'm getting a file and can generate the link with file.link()

But when I use the each function:

FilesCollection.find({'_id': { $in: fileIds } }).each((file) => {
 file.link(); // not executed
});

Each is not executed as if no files were found

Is it a problem that I execute the code on the Serverside?

What I need are the download links to the files.

Gobliins commented 1 year ago

As a workaround it's possible to do: FilesCollection.find().each().map((file) => { .... })