Class: BrickFTP::API::FileOperation::Upload
- Defined in:
- lib/brick_ftp/api/file_operation/upload.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Methods inherited from Base
all, #as_json, #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:, source:) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/brick_ftp/api/file_operation/upload.rb', line 34 def self.create(path:, source:) api_client = BrickFTP::HTTPClient.new step1 = api_client.post(api_path_for(:create, path: path), params: { action: 'put' }) upload_uri = URI.parse(step1['upload_uri']) upload_client = BrickFTP::HTTPClient.new(upload_uri.host) upload_client.put(step1['upload_uri'], params: source) step3 = api_client.post(api_path_for(:create, path: path), params: { action: 'end', ref: step1['ref'] }) new(step1.merge(step3).symbolize_keys) end |