我得到了以下的delayed_job的背:此URI来自于我的应用程序是无效的URI - 如何防止URI :: InvalidURIError错误?
[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
的方式。
在我user_mailer文件我做的:
@comment.attachments.each do |a|
attachments[a.attachment_file_name] = open(a.authenticated_url()) {|f| f.read }
end
然后在我的附件模型:
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
话虽这么说,是有一些类型URI.encode或对其进行解析的,我可以做,以防止有效的URI(因为我检查了URL在我的浏览器中工作),以便在rails 3中进行错误并消除delayed_job?
谢谢!
我想 '开放(URI.parse(URI.encode(a.authenticated_url()))',但与OpenURI :: HTTPError是errord:403禁止 – AnApprentice 2011-01-19 01:01:29
该错误并不意味着网址不好,这意味着该页面不可用。 – 2011-01-19 04:12:27