Class: RepositoryClient::Deposit::Files::DirectUploadRequest
- Inherits:
-
Struct
- Object
- Struct
- RepositoryClient::Deposit::Files::DirectUploadRequest
- Defined in:
- lib/repository_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/repository_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/repository_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/repository_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/repository_client/deposit/files/direct_upload_request.rb', line 8 def filename @filename end |
Class Method Details
.from_file(filename) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/repository_client/deposit/files/direct_upload_request.rb', line 9 def self.from_file(filename) checksum = Digest::MD5.file(filename).base64digest new(checksum: checksum, byte_size: File.size(filename), content_type: 'text/html', filename: File.basename(filename)) end |
Instance Method Details
#as_json ⇒ Object
17 18 19 20 21 |
# File 'lib/repository_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/repository_client/deposit/files/direct_upload_request.rb', line 23 def to_json(*_args) JSON.generate(as_json) end |