When trying to open() remote images, some return as StringIO and others return as File…how do I force the File?
data = open("http://graph.facebook.com/61700024/picture?type=square")
=> #<StringIO:0x007fd09b013948>
data = open("http://28.media.tumblr.com/avatar_7ef57cb42cb0_64.png")
=> #<StringIO:0x007fd098bf9490>
data = open("http://25.media.tumblr.com/avatar_279ec8ee3427_64.png")
=> #<File:/var/folders/_z/bb18gdw52ns0x5r8z9f2ncj40000gn/T/open-uri20120229-9190-mn52fu>
I’m using Paperclip to save remote images (which are stored in S3), so basically wanting to do:
user = User.new
user.avatar = open(url)
user.save
Open-URIhas a10KBlimit onStringIOobjects, anything above that and it stores it as a temp file.One way to get past this is by actually changing the constant that
Open-URItakes for the limit ofStringIOobjects. You can do this by setting the constant to0;Add that to your initialiser and you should be good to go.