IE11、Amazon S3 和 Rails 代理导致图像未 loading/request 中止
IE11, Amazon S3, and a Rails proxy results in images not loading/request aborting
我很困惑,希望有人能提供见解...
我正在构建一个应用程序,该应用程序需要来自同一域的图像,所以我的 Rails 应用程序有一个简单的图像代理,用于存储在 S3 服务器上的文件(替换对域的请求。com/bucket-name /... 使用 s3.amazonaws.com/bucket-name/... 并提供文件内容):
class ProxyController < ActionController::Base
def proxy
image_url = request.protocol + ENV['S3_HOST'] + "#{request.path}"
response.headers['Cache-Control'] = "public, max-age=#{84.hours.to_i}"
response.headers['Content-Disposition'] = 'inline'
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
response.headers['Access-Control-Request-Method'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
text = open(image_url, "rb").read
render :text => text
end
end
路线 config/routes.rb:
get "/" + ENV['S3_BUCKET_NAME'] + "/*other" => "proxy#proxy"
现在在 IE11(迄今为止我测试过的唯一 IE)中,无法加载图片:
<image src='/bucket-name/uploads/images/000/000/018/original/data?1456356347'/>
他们有一个 "X" 失败的图像加载框,开发人员工具中的网络结果显示为“(Aborted)
”,因为收到的结果为 0B。 Rails 服务器正在接收并完成请求:
Completed 200 OK in 1120ms (Views: 0.7ms | ActiveRecord: 0.0ms)
在所有其他浏览器中,我都能很好地加载图像。这发生在本地和 Heroku 托管的生产实例上。
是否有特定于 IE 的东西会影响代理图像?为什么请求会被中止?如果我可以提供更多信息,请告诉我。谢谢!
如果未返回正确的 MIME 类型,或者图像响应中根本没有 MIME 类型,IE 将中止图像下载。
我很困惑,希望有人能提供见解...
我正在构建一个应用程序,该应用程序需要来自同一域的图像,所以我的 Rails 应用程序有一个简单的图像代理,用于存储在 S3 服务器上的文件(替换对域的请求。com/bucket-name /... 使用 s3.amazonaws.com/bucket-name/... 并提供文件内容):
class ProxyController < ActionController::Base
def proxy
image_url = request.protocol + ENV['S3_HOST'] + "#{request.path}"
response.headers['Cache-Control'] = "public, max-age=#{84.hours.to_i}"
response.headers['Content-Disposition'] = 'inline'
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
response.headers['Access-Control-Request-Method'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
text = open(image_url, "rb").read
render :text => text
end
end
路线 config/routes.rb:
get "/" + ENV['S3_BUCKET_NAME'] + "/*other" => "proxy#proxy"
现在在 IE11(迄今为止我测试过的唯一 IE)中,无法加载图片:
<image src='/bucket-name/uploads/images/000/000/018/original/data?1456356347'/>
他们有一个 "X" 失败的图像加载框,开发人员工具中的网络结果显示为“(Aborted)
”,因为收到的结果为 0B。 Rails 服务器正在接收并完成请求:
Completed 200 OK in 1120ms (Views: 0.7ms | ActiveRecord: 0.0ms)
在所有其他浏览器中,我都能很好地加载图像。这发生在本地和 Heroku 托管的生产实例上。
是否有特定于 IE 的东西会影响代理图像?为什么请求会被中止?如果我可以提供更多信息,请告诉我。谢谢!
如果未返回正确的 MIME 类型,或者图像响应中根本没有 MIME 类型,IE 将中止图像下载。