Meteor File Uploads

前端 未结 5 1776
[愿得一人]
[愿得一人] 2021-02-07 15:14

I see that this has been asked here before, but nothing since Meteor.http has been available. I\'m still grasping the concepts of Meteor and file uploads are totall

5条回答
  •  忘了有多久
    2021-02-07 15:44

    Take a look at filepicker.io. They handle the upload, store it into your S3, and return to you the url that you can dump into your db.

    1. Wget the filepicker script into your client folder.

      wget https://api.filepicker.io/v0/filepicker.js
      
    2. Insert a filepicker input tag

      
      
    3. In the startup, initialize it:

      Meteor.startup( function() {
          filepicker.setKey("YOUR FILEPICKER API KEY");
          filepicker.constructWidget(document.getElementById('attachment'));
      });
      
    4. Attach a event handler

      Template.templateNameHere.events({
          'change #attachment': function(evt){
              console.log(evt.files);
          }
      });
      

    (I had posted on How would one handle a file upload with Meteor? Sorry. I'm new here. Is it kosher to copy the same answer twice? Anyone who knows better can feel free to edit this.)

提交回复
热议问题