Sha256: 4332ea30288f5aa1a333967eb6674f2bedb7f5ff76000250a55606e511fcb7af
Contents?: true
Size: 1.6 KB
Versions: 17
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true require 'logger' module SdrClient module Deposit # Collecting all the metadata about the files for a deposit class UploadFilesMetadataBuilder # @param [Array<String>] files a list of relative filepaths to upload # @param [Hash<String,String>] mime_types a map of filenames to mime types # @param [String] basepath path to which files are relative # @return [Hash<String, Files::DirectUploadRequest>] the metadata for uploading the files def self.build(files:, mime_types:, basepath:) new(files: files, mime_types: mime_types, basepath: basepath).build end # @param [Array<String>] files a list of absolute filepaths to upload # @param [Hash<String,String>] mime_types a map of filenames to mime types # @param [String] basepath path to which files are relative def initialize(files:, mime_types:, basepath:) @files = files @mime_types = mime_types @basepath = basepath end attr_reader :files, :mime_types, :basepath # @return [Hash<String, Files::DirectUploadRequest>] the metadata for uploading the files def build files.each_with_object({}) do |filepath, obj| obj[filepath] = Files::DirectUploadRequest.from_file(absolute_filepath_for(filepath), file_name: filepath, content_type: mime_types[filepath]) end end def absolute_filepath_for(filepath) ::File.join(basepath, filepath) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems