Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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 使用远程资源url在carrierwave rails中上载文件时未复制或设置Mime类型_Ruby On Rails_Amazon S3_Carrierwave - Fatal编程技术网

Ruby on rails 使用远程资源url在carrierwave rails中上载文件时未复制或设置Mime类型

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

我正在使用远程资源url将文件从临时s3上传到永久s3

临时s3中的内容类型是正确的,但是当我将文件复制到永久s3时,内容类型被设置为八位字节流,这导致下载文件/pdf而不是内联浏览。是否有一种方法可以在使用远程资源url时设置内容类型?我的代码如下所示:

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