Meteor Upload to AWS S3 -


i have meteor app in insert document (title, description, customer, ...) database. app using autoform, simple schema , collection2. want add possibility upload file s3.

to keep things simple, present filepicker part of 'create document' , once file uploaded, url field (from autoform), should show url of document on s3 (once uploaded) url stored in document collection when create button clicked. realise there might better ways, wanted keep things simple now.

i have tried combine tutorial here. upload s3 works, fail url uploaded file stored documents collection. below screenshot shows layout. idea's? screenshot

my current code can found here.

there appear autoform add-on packages address s3 file upload (see "files" section here), since seem using learning opportunity, i'll try explain how i'd using core meteor.

but first, before forget, uploader template child of #autoform has form element of it's own. think cause generated html have nested form elements (which no-no). fix that, i'd move {{/autoform}} before {{> uploader}} , add event handler submit button submits form using $('#documentform').submit(). note: haven't tested that.

now, on actual question. asking how modify in template (the value of url field) event in nested template (the uploader template). i'd follows:

  1. when instance of parent template created, attach reactivevar hold url of uploaded file.

    template.admindocumentnew.oncreated(function () {   this.url = new reactivevar(); }); 
  2. provide helper reactive var.

    template.admindocumentnew.helpers({   url: function () {     return template.instance().url;   } }); 
  3. use helper set value in form.

    {{> afquickfield name='url' value=url.get}} 
  4. pass reactive var uploader template data context:

    {{> uploader urlvar=url}} 
  5. use reactive var set url when upload finishes (somewhere in upload-to-amazon-s3):

    template.data.urlvar.set(url); 

i've created a meteorpad demonstrates basic idea outside of context of autoform , s3.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -