Class: Backblaze::B2::FileVersion
- Defined in:
- lib/backblaze/b2/file_version.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#content_length ⇒ Object
readonly
Returns the value of attribute content_length.
-
#content_sha1 ⇒ Object
readonly
Returns the value of attribute content_sha1.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#file_id ⇒ Object
readonly
Returns the value of attribute file_id.
-
#file_info ⇒ Object
readonly
Returns the value of attribute file_info.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#upload_timestamp ⇒ Object
readonly
Returns the value of attribute upload_timestamp.
Instance Method Summary collapse
- #destroy! ⇒ Object
- #download_url ⇒ Object
- #exists? ⇒ Boolean
- #get_info ⇒ Object
-
#initialize(file_id:, size:, upload_timestamp:, action:, file_name:, content_length:, content_sha1:, content_type:, file_info: {}, **unneeded_args) ⇒ FileVersion
constructor
A new instance of FileVersion.
Methods inherited from Base
Methods included from Utils
#camelize, included, #underscore
Constructor Details
#initialize(file_id:, size:, upload_timestamp:, action:, file_name:, content_length:, content_sha1:, content_type:, file_info: {}, **unneeded_args) ⇒ FileVersion
Returns a new instance of FileVersion.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/backblaze/b2/file_version.rb', line 6 def initialize(file_id:, size:, upload_timestamp:, action:, file_name:, content_length:, content_sha1:, content_type:, file_info: {}, **unneeded_args) @file_id = file_id @size = size @action = action @file_name = file_name @content_length = content_length @content_sha1 = content_sha1 @content_type = content_type @file_info = file_info @upload_timestamp = Time.at( / 1000.0) end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def action @action end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def content_length @content_length end |
#content_sha1 ⇒ Object (readonly)
Returns the value of attribute content_sha1.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def content_sha1 @content_sha1 end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def content_type @content_type end |
#file_id ⇒ Object (readonly)
Returns the value of attribute file_id.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def file_id @file_id end |
#file_info ⇒ Object (readonly)
Returns the value of attribute file_info.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def file_info @file_info end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def file_name @file_name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def size @size end |
#upload_timestamp ⇒ Object (readonly)
Returns the value of attribute upload_timestamp.
3 4 5 |
# File 'lib/backblaze/b2/file_version.rb', line 3 def @upload_timestamp end |
Instance Method Details
#destroy! ⇒ Object
33 34 35 36 37 |
# File 'lib/backblaze/b2/file_version.rb', line 33 def destroy! response = post('/b2_delete_file_version', body: { fileName: file_name, fileId: file_id }.to_json) raise Backblaze::FileError, response unless response.code == 200 @destroyed = true end |
#download_url ⇒ Object
29 30 31 |
# File 'lib/backblaze/b2/file_version.rb', line 29 def download_url "#{Backblaze::B2.download_url}#{Backblaze::B2.api_path}b2_download_file_by_id?fileId=#{file_id}" end |
#exists? ⇒ Boolean
39 40 41 |
# File 'lib/backblaze/b2/file_version.rb', line 39 def exists? !@destroyed end |
#get_info ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/backblaze/b2/file_version.rb', line 19 def get_info unless defined?(@get_info) response = post('/b2_get_file_info', body: { fileId: file_id }.to_json) raise Backblaze::FileError, response unless response.code == 200 @get_info = Hash[response.map { |k, v| [Backblaze::Utils.underscore(k).to_sym, v] }] end @get_info end |