Reputation: 523
I am newbie user of meteor. I am using file picker apis , i can easily upload my files to there server and they give me a unique url in return . When it comes to again fetch that file its creating a problem to me .
You can tell me how to get back file using that url by using filepicker api . You can tell me how to use that url and get image , by using meteor When i upload a picture to filepicker.io they return me a json object like following
[{"url":"https://www.filepicker.io/api/file/kIrtNvQRta7GxlFVfiP2","filename":"brazil.jpg","mimetype":"image/jpeg","size":2660,"key":"ZML3OjrFTVyV4waBzRIT_brazil.jpg","isWriteable":true}]
So how to get the image on meteor? Thank You in advance
Upvotes: 0
Views: 1047
Reputation: 75945
The normal image source should work:
<template name="image">
<img src="{{img}}"/>
</template>
and your javascript to give it the url
Template.image.img = function() {
var yourfilepickerjson = [{"url":"https://www.filepicker.io/api/file/kIrtNvQRta7GxlFVfiP2","filename":"brazil.jpg","mimetype":"image/jpeg","size":2660,"key":"ZML3OjrFTVyV4waBzRIT_brazil.jpg","isWriteable":true}]
return yourfilepickerjson[0] && yourfilepickerjson[0].url;
}
You could pass the filepickerjson via Session
object so that its reflected reactively as soon as you get it
Upvotes: 1