app/models/concerns/bulkrax/export_behavior.rb
# Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
def filename(file_set)
      return if file_set.original_file.blank?
      fn = file_set.original_file.file_name.first
      mime = Mime::Type.lookup(file_set.original_file.mime_type)
      ext_mime = MIME::Types.of(file_set.original_file.file_name).first
      if fn.include?(file_set.id) || importerexporter.metadata_only?
        filename = "#{fn}.#{mime.to_sym}"
        filename = fn if mime.to_s == ext_mime.to_s
      else
        filename = "#{file_set.id}_#{fn}.#{mime.to_sym}"
        filename = "#{file_set.id}_#{fn}" if mime.to_s == ext_mime.to_s
      end
      ext = File.extname(filename)
      "#{File.basename(filename, ext)[0...(220 - ext.length)]}#{ext}"
    end
def filename ( file_set ) return if file_set . original_file . blank? fn = file_set . original_file . file_name . first mime = Mime :: Type . lookup ( file_set . original_file . mime_type ) ext_mime = MIME :: Types . of ( file_set . original_file . file_name ) . first if fn . include? ( file_set . id ) || importerexporter . metadata_only? filename = "#{fn}.#{mime.to_sym}" filename = fn if mime . to_s == ext_mime . to_s else filename = "#{file_set.id}_#{fn}.#{mime.to_sym}" filename = "#{file_set.id}_#{fn}" if mime . to_s == ext_mime . to_s end ext = File . extname ( filename ) "#{File.basename(filename, ext)[0...(220 - ext.length)]}#{ext}" end
Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters
# Remove extention truncate and reattach
file_set