Created
May 6, 2014 23:50
-
-
Save acidsound/8729aac5e5051967f044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="basic"> | |
{{#with stuff}} | |
{{#S3 callback="savedURL"}} | |
<input type="file"> | |
{{/S3}} | |
{{/with}} | |
{{#each savedURL}} | |
<p>SAVED URL: {{url}}</p> | |
{{/each}} | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UploadKeys = new Meteor.Collection('uploadKeys'); | |
if (Meteor.isServer) { | |
Meteor.methods({ | |
save_url: function(url,context){ | |
UploadKeys.insert({ | |
key: context.key, | |
url: url | |
}); | |
} | |
}); | |
} | |
if (Meteor.isClient) { | |
Template.basic.rendered = function() { | |
// 중복 방지용 unique key 생성 | |
Template.basic.setUploadKey(); | |
}; | |
Template.basic.helpers({ | |
"stuff": function() { | |
return { | |
key: Session.get('uploadKey') | |
}; | |
}, | |
"setUploadKey": function() { | |
Session.set('uploadKey', Meteor.uuid()); | |
}, | |
// 업로드 후 reactive로 URL을 받도록 | |
"savedURL": function() { | |
var res = UploadKeys.find({ | |
key: Session.get('uploadKey') | |
}); | |
res.observe({ | |
'added': function(o) { | |
// URL을 받는 시점에 실행 | |
console.log('uploaded', o.url); | |
} | |
}); | |
return res; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment