0

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

Bhim Prasad Ale
  • 523
  • 1
  • 8
  • 31

1 Answers1

1

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

Tarang
  • 75,157
  • 39
  • 215
  • 276
  • it just show the repective images... i need to show the images once uploaded dynamically.@Akshat – Bhim Prasad Ale Jul 15 '13 at 09:46
  • Yes you can retreive `yourfilepickerson` from a `Session.get("yourvariablename")`. As soon as you set the value with `Session.set("yourvariablename", )` it should update automatically. – Tarang Jul 15 '13 at 14:04