Erwin
2011-Jun-14 21:26 UTC
[open-uri] cannot parse correctly a file with a dot inside the filename ...
I have some big issue in opening one file ...
currently I am writing
require ''open-uri''
..
io = open(URI.parse(thumbnail_url))
def io.original_filename; base_uri.path.split(''/'').last;
end
io.original_filename.blank? ? nil : io
this one ( and similar) open very well
thumbnail_url = "http://video.vertexdigitalsports.com//sitehome/site41/
userUpload/ID7bcfa7ff-63d0-4564-ad22-5c7a233d4890/
JoeFBVideo2328_thumbnail.png"
I get
#<File:/var/folders/NK/NKfWCW3eEVCg0ERnpPsnME+++TI/-Tmp-/open-
uri20110614-5150-1frj7ah>
but trying to open this one .. ( there is a dot in the filename ...
thumbnail_url = "http://video.vertexdigitalsports.com//sitehome/site41/
userUpload/ID856657ea-1f86-4937-904c-04852ca94ad1/
PerformanceManagementVideoVer1.32430_thumbnail.png"
I get
#<StringIO:0x0000010702e15> and this raises an exception in my app..
I tried to use ''addressable/uri)
require ''addressable/uri''
uri = Addressable::URI.parse(thumbnail_url)
open(uri.normalize.to_s) {|f| p f.status } => ["200",
"OK"]
then
io = open(uri.normalize.to_s) {|f| f.read }
but this is not right ...
what should I rather write ?
thanks for your feedback
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.