Class: BrickFTP::API::FileOperation::UploadingSession
- Includes:
- Enumerable
- Defined in:
- lib/brick_ftp/api/file_operation/uploading_session.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.create(path:) ⇒ BrickFTP::API::FileOperation::UploadingSession
Get uploading URL.
-
.upload(upload_uri:, data:) ⇒ Object
Upload data.
Instance Method Summary collapse
-
#as_json(*_args) ⇒ Hash
Return single uploading session object.
-
#at(part_number) ⇒ BrickFTP::API::FileOperation::UploadingSession
Get uploading URL for multi part uploading.
-
#commit ⇒ BrickFTP::API::FileOperation::UploadingResult
Complete uploading file.
-
#each {|session| ... } ⇒ Object
Get each uploading URLs.
Methods inherited from Base
all, #delete_property, #destroy, find, inherited, #initialize, #read_property, #to_json, #update, #write_property
Constructor Details
This class inherits a constructor from BrickFTP::API::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BrickFTP::API::Base
Class Method Details
.create(path:) ⇒ BrickFTP::API::FileOperation::UploadingSession
Get uploading URL.
32 33 34 35 36 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 32 def self.create(path:) api_client = BrickFTP::HTTPClient.new res = api_client.post(api_path_for(:create, path: path), params: { action: 'put' }) new(res.symbolize_keys) end |
.upload(upload_uri:, data:) ⇒ Object
Upload data.
43 44 45 46 47 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 43 def self.upload(upload_uri:, data:) uri = URI.parse(upload_uri) upload_client = BrickFTP::HTTPClient.new(uri.host) upload_client.put(uri.to_s, params: data) end |
Instance Method Details
#as_json(*_args) ⇒ Hash
Return single uploading session object.
NOTE: The #as_json method will be overwritten by active_supprt.
89 90 91 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 89 def as_json(*_args) properties.dup end |
#at(part_number) ⇒ BrickFTP::API::FileOperation::UploadingSession
Get uploading URL for multi part uploading.
54 55 56 57 58 59 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 54 def at(part_number) params = { action: 'put', ref: ref, part: part_number } api_client = BrickFTP::HTTPClient.new res = api_client.post(self.class.api_path_for(:create, path: path), params: params) self.class.new(res.symbolize_keys) end |
#commit ⇒ BrickFTP::API::FileOperation::UploadingResult
Complete uploading file.
79 80 81 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 79 def commit UploadingResult.create(path: path, ref: ref) end |
#each {|session| ... } ⇒ Object
Get each uploading URLs.
66 67 68 69 70 71 72 73 |
# File 'lib/brick_ftp/api/file_operation/uploading_session.rb', line 66 def each return enum_for(__method__) unless block_given? yield self (part_number + 1).upto(available_parts) do |n| yield at(n) end end |