2019-09-24 17:42:50 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# CarrierWave uploader for import files.
|
|
|
|
# This file defines the parameters for these uploads
|
|
|
|
class ImportUploader < CarrierWave::Uploader::Base
|
|
|
|
include UploadHelper
|
|
|
|
|
|
|
|
# Choose what kind of storage to use for this uploader:
|
|
|
|
storage :file
|
|
|
|
after :remove, :delete_empty_dirs
|
|
|
|
|
|
|
|
# Override the directory where uploaded files will be stored.
|
|
|
|
# This is a sensible default for uploaders that are meant to be mounted:
|
|
|
|
|
|
|
|
def store_dir
|
|
|
|
"#{base_store_dir}/#{model.id}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_store_dir
|
|
|
|
'../imports'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Add a white list of extensions which are allowed to be uploaded.
|
|
|
|
# For images you might use something like this:
|
2024-03-11 12:46:39 +01:00
|
|
|
def extension_allowlist
|
2020-06-02 17:57:24 +02:00
|
|
|
%w[csv]
|
2019-09-24 17:42:50 +02:00
|
|
|
end
|
2020-06-02 19:18:57 +02:00
|
|
|
|
2024-03-11 12:46:39 +01:00
|
|
|
def content_type_allowlist
|
2020-06-02 19:18:57 +02:00
|
|
|
%w[text/csv]
|
|
|
|
end
|
|
|
|
|
2019-09-24 17:42:50 +02:00
|
|
|
end
|