CuriousNewbie
2011-Jan-19 01:38 UTC
InvalidURIError - how to clean up URIs before using .open()
Hello, I got the following back from delayed_job:
[Worker(XXXXXX pid:3720)] Class#XXXXXXX failed with
URI::InvalidURIError: bad URI(is not URI?):
https://s3.amazonaws.com/cline-local-dev/2/attachments/542/original/mac-os-x[1].jpeg?AWSAccessKeyId=xxxxxxxx&Expires=1295403309&Signature=xxxxxxx%3D
- 3 failed attempts
The way this URI comes from in my app is:
In my user_mailer I do:
@comment.attachments.each do |a|
attachments[a.attachment_file_name] open(a.authenticated_url()) {|f|
f.read }
end
Then in my attachments model:
def authenticated_url(style = nil, expires_in = 90.minutes)
AWS::S3::S3Object.url_for(attachment.path(style ||
attachment.default_style), attachment.bucket_name, :expires_in =>
expires_in, :use_ssl => attachment.s3_protocol == ''https'')
end
That being said, is there some type of URI.encode or parsing I can do
to prevent a valid URI (as I checked the URL works in my browser) for
erroring and killing delayed_job in rails 3?
Thank you!
--
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.
Hassan Schroeder
2011-Jan-19 05:00 UTC
Re: InvalidURIError - how to clean up URIs before using .open()
On Tue, Jan 18, 2011 at 5:38 PM, CuriousNewbie <bhellman1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, I got the following back from delayed_job: > > [Worker(XXXXXX pid:3720)] Class#XXXXXXX failed with > URI::InvalidURIError: bad URI(is not URI?): > https://s3.amazonaws.com/cline-local-dev/2/attachments/542/original/mac-os-x[1].jpeg?AWSAccessKeyId=xxxxxxxx&Expires=1295403309&Signature=xxxxxxx%3D> That being said, is there some type of URI.encode or parsing I can do > to prevent a valid URI (as I checked the URL works in my browser) forerroring... and, sorry, that *doesn''t* mean it''s valid. via: http://www.ietf.org/rfc/rfc1738.txt <q> Other characters are unsafe because gateways and other transport agents are known to sometimes modify such characters. These characters are "{", "}", "|", "\", "^", "~", "[", "]", and "`". All unsafe characters must always be encoded within a URL. </q> HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
CuriousNewbie
2011-Jan-19 05:50 UTC
Re: InvalidURIError - how to clean up URIs before using .open()
Thank you. What''s the best way to Encode All Unsafe Characters? And should that be done in the model? or in the mailer? On Jan 18, 9:00 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Jan 18, 2011 at 5:38 PM, CuriousNewbie <bhellm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, I got the following back from delayed_job: > > > [Worker(XXXXXX pid:3720)] Class#XXXXXXX failed with > > URI::InvalidURIError: bad URI(is not URI?): > >https://s3.amazonaws.com/cline-local-dev/2/attachments/542/original/m...[1].jpeg?AWSAccessKeyId=xxxxxxxx&Expires=1295403309&Signature=xxxxxxx%3D > > That being said, is there some type of URI.encode or parsing I can do > > to prevent a valid URI (as I checked the URL works in my browser) for > > erroring... > > and, sorry, that *doesn''t* mean it''s valid. > > via:http://www.ietf.org/rfc/rfc1738.txt > > <q> > Other characters are unsafe because > gateways and other transport agents are known to sometimes modify > such characters. These characters are "{", "}", "|", "\", "^", "~", > "[", "]", and "`". > > All unsafe characters must always be encoded within a URL. > </q> > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.