Sha256: 7e014f56b6004b8a1f8ada23ac26cce10d6d010f276a8abc5832a40c42f665f3
Contents?: true
Size: 795 Bytes
Versions: 121
Compression:
Stored size: 795 Bytes
Contents
# frozen_string_literal: true require 'digest' module SdrClient module Deposit module Files DirectUploadRequest = Struct.new(:checksum, :byte_size, :content_type, :filename, keyword_init: true) do def self.from_file(path, file_name:, content_type:) checksum = Digest::MD5.file(path).base64digest new(checksum: checksum, byte_size: ::File.size(path), content_type: content_type || 'application/octet-stream', filename: file_name) end def as_json { blob: { filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type } } end def to_json(*_args) JSON.generate(as_json) end end end end end
Version data entries
121 entries across 121 versions & 1 rubygems