开发者

Paperclip Remote URL

I'm working with Rails 3.0.9 and Ruby 1.9.2. I am running the gem Paperclip to upload images, and this works fine.

However, I'm trying to integrate it with an API that returns just an image URL.

The plan is to r开发者_JAVA技巧un a cron job to fetch the XML output of the API, parse it, and store it in the database.

My question is, how can I use just the remote url to display the image in my application? I do not want to have to download all the images, as there are 1000s of images (only 1 per record though).

Can anyone suggest how to do this? Thanks in advance.


Sure in the latest version of paperclip (you might have to link it to the unreleased version in github). (Version > 3.1.3)

You can do something like this

self.your_paperclip_attachment_attribute = URI.parse("http://some.com/url/withimage.png")

That will download and link the attachment to your model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜