Sha256: 98cd19bba7ab5b9e19ffd05d2b01e762ecd6d6c50c84059f2a68a37ce9d1b7f2

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

# -*- encoding : utf-8 -*-
require "paperclip"

module PolicyManager::Concerns::PaperclipBehavior
  extend ActiveSupport::Concern
  include Paperclip::Glue

  included do

    has_attached_file :attachment,
      path: Config.exporter.try(:attachment_path) || Rails.root.join("tmp/portability/:id/build.zip").to_s,
      storage: Config.exporter.try(:attachment_storage) || :filesystem,
      s3_permissions: :private

    do_not_validate_attachment_file_type :attachment
  end

  def file_remote_url=(url_value)
    self.attachment = File.open(url_value) unless url_value.blank?
    self.save
    self.complete!
  end

  def download_link
    url = self.attachment.expiring_url(PolicyManager::Config.exporter.expiration_link)
    PolicyManager::Config.exporter.customize_link(url)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gdpr_rails-0.5.1 app/models/policy_manager/concerns/paperclip_behavior.rb
gdpr_rails-0.5.0 app/models/policy_manager/concerns/paperclip_behavior.rb