Mime type not getting copied or set while using remote_asset_url to upload files in carrierwave rails

Viewed 102

I am using remote_asset_url to upload the files from temp s3 to permanent s3.

the content type in temporary s3 is correct but when i copy the file to permanent s3 the content type is set to octet-stream which leads to downloading the files/pdf instead of browsing inline. Is there a way I can sett the content type while using the remote_asset_url? My code is like following:

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

0 Answers
Related