Class: SdrClient::Deposit::Files::DirectUploadRequest
- Inherits:
-
Struct
- Object
- Struct
- SdrClient::Deposit::Files::DirectUploadRequest
- Defined in:
- lib/sdr_client/deposit/files/direct_upload_request.rb
Instance Attribute Summary collapse
-
#byte_size ⇒ Object
Returns the value of attribute byte_size.
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#filename ⇒ Object
Returns the value of attribute filename.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#byte_size ⇒ Object
Returns the value of attribute byte_size
8 9 10 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 8 def byte_size @byte_size end |
#checksum ⇒ Object
Returns the value of attribute checksum
8 9 10 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 8 def checksum @checksum end |
#content_type ⇒ Object
Returns the value of attribute content_type
8 9 10 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 8 def content_type @content_type end |
#filename ⇒ Object
Returns the value of attribute filename
8 9 10 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 8 def filename @filename end |
Class Method Details
.from_file(path, file_name:, content_type:) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 9 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 |
Instance Method Details
#as_json ⇒ Object
17 18 19 20 21 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 17 def as_json { blob: { filename: filename, byte_size: byte_size, checksum: checksum, content_type: content_type } } end |
#to_json(*_args) ⇒ Object
23 24 25 |
# File 'lib/sdr_client/deposit/files/direct_upload_request.rb', line 23 def to_json(*_args) JSON.generate(as_json) end |