<ActiveRecord :: RecordInvalid:验证失败:文件无法下载文件:403禁止>

时间:2020-04-29 20:34:11

标签: ruby-on-rails amazon-s3 activerecord carrierwave http-status-code-403

我正在尝试从S3下载图像文件,并尝试将其上传到我的数据库。我的模型文件中包含以下行

mount_base64_uploader :file, ApplicationUploader, file_name: ->(_) { Time.now.to_i }

我的上传器文件如下所示

class ApplicationUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  #include ::CarrierWave::Backgrounder::Delay

  process :strip, if: :not_svg?, if: :process_uri

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  private

  # Strips out all embedded information from the image
  def strip
    manipulate! do |img|
      img.strip
      img = yield(img) if block_given?
      img
    end
  end

   def process_uri(uri)
    debugger
    URI.parse(uri)
  end
end

但是,我要例外

**<ActiveRecord::RecordInvalid: Validation failed: File could not download file: 403 Forbidden>**

下载文件时

在下载之前如何忽略此文件?

0 个答案:

没有答案
相关问题