Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 回形针和S3的图像内容类型错误_Ruby On Rails 3_Amazon S3_Paperclip_Content Type - Fatal编程技术网

Ruby on rails 3 回形针和S3的图像内容类型错误

Ruby on rails 3 回形针和S3的图像内容类型错误,ruby-on-rails-3,amazon-s3,paperclip,content-type,Ruby On Rails 3,Amazon S3,Paperclip,Content Type,我想限制我的用户的化身。为此,在我的用户模型中,我添加了:s3\u权限: has_attached_file :avatar, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :s3_permissions => :private, :pat

我想限制我的用户的化身。为此,在我的用户模型中,我添加了
:s3\u权限

 has_attached_file :avatar,
                   :storage => :s3,
                   :s3_credentials => "#{Rails.root}/config/s3.yml",
                   :s3_permissions => :private,
                   :path => "avatars/:id/:filename"
在我的用户控制器中:

def get_avatar
  redirect_to @user.avatar.expiring_url(10)
end
当用户调用此方法时,例如通过带有浏览器的API,他们下载图像,而不是显示图像

我注意到我下载的图像的内容类型是:

content-type application/octet-stream
所以我想,也许这是一个解释事实的理由


如何显示图像而不是下载图像?

您应该在自己上载图像时设置内容类型。S3不会为您猜测/设置内容类型