Ruby on rails 使用远程资源url在carrierwave rails中上载文件时未复制或设置Mime类型
我正在使用远程资源url将文件从临时s3上传到永久s3 临时s3中的内容类型是正确的,但是当我将文件复制到永久s3时,内容类型被设置为八位字节流,这导致下载文件/pdf而不是内联浏览。是否有一种方法可以在使用远程资源url时设置内容类型?我的代码如下所示:Ruby on rails 使用远程资源url在carrierwave rails中上载文件时未复制或设置Mime类型,ruby-on-rails,amazon-s3,carrierwave,Ruby On Rails,Amazon S3,Carrierwave,我正在使用远程资源url将文件从临时s3上传到永久s3 临时s3中的内容类型是正确的,但是当我将文件复制到永久s3时,内容类型被设置为八位字节流,这导致下载文件/pdf而不是内联浏览。是否有一种方法可以在使用远程资源url时设置内容类型?我的代码如下所示: begin self.remote_asset_url = self.absolute_url self.save! rescue CarrierWave::DownloadError => ex
begin
self.remote_asset_url = self.absolute_url
self.save!
rescue CarrierWave::DownloadError => ex
if ex.message.include?("Invalid Location URI")
# "http://www.hiretale.com/files/resize_logo/13126logo original.png"
# is not working without doing this due to redirect URL not encoded properly
page = Mechanize.new.head(self.absolute_url)
self.remote_asset_url = page.uri.to_s
self.save!
elsif self.parent.is_a?(::UserProfile)
self.destroy
else
raise ex
end
end