Upload files and images, the correct way?


#1

Hi there,

In the doc there is no explicit way to upload images and files. Where we can find the best practice to achieve this kind of things ?

Is there a package or a npm module that is supported by the Meteor team ?

Thank’s


#2

Hey

Check https://guide.meteor.com/structure.html#special-directories out

Quoted,

“All files inside a top-level directory called public/ are served as-is to the client. When referencing these assets, do not include public/ in the URL, write the URL as if they were all in the top level. For example, reference public/bg.png as <img src='/bg.png' />. This is the best place for favicon.ico, robots.txt, and similar files.”

Were you asking about that?

Or, about uploading files through the form?

If you were asking about uploading stuff, then - no - I don’t think there are any Meteor “uploading package”. That is perhaps because there can be various implementations. See https://github.com/meteor/guide/issues/29

I do know that Galaxy does not recommend storing files on their server, they suggest using some third-party store like S3.

Hope that helps


PS: You could try https://www.filestack.com/ (previously http://filepicker.io) like so,

<input type="filepicker" id="attachment">
Meteor.startup( function() {
    filepicker.setKey("YOUR FILEPICKER API KEY");
    filepicker.constructWidget(document.getElementById('attachment'));
});
Templates.template.events({
    'change #attachment': function(evt){
        console.log(evt.files);
    }
});

Fair warning though: I haven’t used this in production so I don’t know how this will behave there. I just tried it out and it works like a charm. See https://www.filestack.com/docs/file-ingestion/javascript-api/pick

Note, https://www.filestack.com/ is a paid service


#3

Hi. CollectionFS appears to be deprecated and I am using Lepozepo package to upload files to S3. Works with most file formats including .mov and .zip files. I chose it for its simplicity to use.


#4

@dbx834 I’m trying to uploading files through forms. It will be image type files mostly. Your solution seems great but it’s a paid service, do you know a free service that will do basically the same thing ?

@youngone I heard about CollectionFS but like you said before it’s now deprecated… I will take a look at Lepozepo package.

Do you both know a service that allow uploading files for free ? I’m talking about small files like images with a size less than 1 Mo.


#5

The free s3 tier should be plenty?


#6

I would recommend to use https://github.com/CulturalMe/meteor-slingshot to upload to s3. It uploads directly from client to s3 instead of using your server as a proxy.

It’s really simple to use


#7

Does the storage on S3 not expire after a year?


#8

I guess when I think of free services, I expect them to be limited in some way…