5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/concerns/interpret_files_behavior.rb', line 5
def interpret_file_fields
@raw_row.each do |field, value|
next if value.blank? or field.blank?
field = field.to_s
next if field == value
next unless (action = BulkOps::Verification.is_file_field?(field))
next if find_field_name(field)
if action == "remove"
get_removed_filesets(value).each { |fileset_id| delete_file_set(file_set_id) }
else
operation.get_file_paths(value).each do |filepath|
begin
uploaded_file = Hyrax::UploadedFile.create(file: File.open(filepath), user: operation.user)
(@metadata[:uploaded_files] ||= []) << uploaded_file.id unless uploaded_file.id.nil?
rescue Exception => e
report_error(:upload_error,
message: "Error opening file: #{ filepath } -- #{e}",
file: File.join(BulkOps::INGEST_MEDIA_PATH,filename),
row_number: row_number)
end
end
end
i = 1
while self.class.is_file_set?(@metadata,row_number+i)
child_row.each do |field,value|
next if value.blank?
title = value if ["title","label"].include?(field.downcase.strip)
if BulkOps::Verification.is_file_field?(field)
operation.get_file_paths(value).each do |filepath|
uploaded_file = Hyrax::UploadedFile.create(file: File.open(filepath), user: operation.user)
end
end
end
i+=1
end
end
end
|