I have a JSON snippet that I am fetching to save posts to Post
model
It looks like this:
{
"provider_url": "http://twitter.com",
"description": "Four more years. pic.twitter.com/bAJE6Vom",
"title": "Twitter / BarackObama: Four more years. http://t.co/bAJE6Vom",
"author_name": "BarackObama", "height": 532, "thumbnail_width": 150, "width": 800,
"thumbnail_url": "https://pbs.twimg.com/media/A7EiDWcCYAAZT1D.jpg:thumb",
"author_url": "http://twitter.com/BarackObama", "version": "1.0",
"url": "https://pbs.twimg.com/media/A7EiDWcCYAAZT1D.jpg:large",
"provider_name": "Twitter", "type": "photo", "thumbnail_height": 150
}
The image being saved is the original photo URL from the provider.
For example: https://pbs.twimg.com/media/A7EiDWcCYAAZT1D.jpg
I want to archive the image into my own Amazon S3 storage using Paperclip if possible.
I also have a Post
column named backup_s3_url
where I want to store my uploaded/duplicated image URL hosted by S3.
I tried to use open-uri
still... But it's still getting the original image URL. I want to directly save the image from URL using paperclip.
def picture_from_url(url)
self.photo = URI.parse(url)
end
But the code above doesn't work, FYI.
Any workarounds will be appreciated.