Class: AttachFilesToWorkJob
- Inherits:
-
Hyrax::ApplicationJob
- Object
- ActiveJob::Base
- Hyrax::ApplicationJob
- AttachFilesToWorkJob
- Defined in:
- app/jobs/attach_files_to_work_job.rb
Overview
Converts UploadedFiles into FileSets and attaches them to works.
Instance Method Summary collapse
Instance Method Details
#perform(work, uploaded_files, **work_attributes) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/jobs/attach_files_to_work_job.rb', line 7 def perform(work, uploaded_files, **work_attributes) validate_files!(uploaded_files) user = User.find_by_user_key(work.depositor) # BUG? file depositor ignored = work..map(&:to_hash) = visibility_attributes(work_attributes) uploaded_files.each do |uploaded_file| actor = Hyrax::Actors::FileSetActor.new(FileSet.create, user) actor.() actor.create_content(uploaded_file) actor.attach_to_work(work) actor.file_set. = uploaded_file.update(file_set_uri: actor.file_set.uri) end end |