Meteor-Files icon indicating copy to clipboard operation
Meteor-Files copied to clipboard

HTML get()

Open dpatte opened this issue 1 year ago • 3 comments

I have converted my gridfs from vsivsi:FileCollection format to ostrio:FilesCollection format, but I have a suggestion:

One of the nice features of vsivsi:FileCollection was a HTML get() method for file collections.

My existing templates are sprinkled with lines like this:

<img src="/gridfs/imagepage/nasa.jpg">

Which automatically finds and pulls in the gridfs image to the resulting page.

I see that you provide other ways to pull in gridfs files from within a template, but for people moving from vsivsi to ostrio, the only solutions i see available would mean changes to hundreds of templates on our sites, unless I missed something.

dpatte avatar Apr 05 '25 20:04 dpatte

@dpatte How do you know URL/name of each uploaded file?

I assume you can come up with thin middleware that will redirect existing URLs that start with /gridfs/ to the actual file in FileCollection, wdyt?

dr-dimitru avatar Apr 06 '25 15:04 dr-dimitru

the URL is always /gridfs/cpllectionname/filename.ext But this infers that all filenames in a single collection must be unique - something i never noticed before..

Yes I am looking to make a helper to handle it at this point which will mean minimal changes.

dpatte avatar Apr 06 '25 19:04 dpatte

@dpatte As long as the name is unique, you can find the right file using its object or its meta object. Then use .serve method to return file over HTTP within the same middleware

P.S. don't forget make add index for name (double check property name though)

dr-dimitru avatar Apr 07 '25 05:04 dr-dimitru

@dpatte have you figured this one out?

dr-dimitru avatar Sep 24 '25 07:09 dr-dimitru

@dpatte I saw you have migrated to other "files-collection" library, closing this for now

Feel free to reopen it in case if the issue is still persists on your end.

dr-dimitru avatar Sep 24 '25 15:09 dr-dimitru