Class: Files::FileAction
- Inherits:
-
Object
- Object
- Files::FileAction
- Defined in:
- lib/files.com/models/file_action.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.begin_upload(path, params = {}, options = {}) ⇒ Object
Begin file upload.
-
.copy(path, params = {}, options = {}) ⇒ Object
Copy file/folder.
-
.move(path, params = {}, options = {}) ⇒ Object
Move file/folder.
Instance Method Summary collapse
-
#begin_upload(params = {}) ⇒ Object
Begin file upload.
-
#copy(params = {}) ⇒ Object
Copy file/folder.
-
#file_migration_id ⇒ Object
int64 - If status is enqueued, this is the id of the FileMigration to check for status updates.
-
#initialize(attributes = {}, options = {}) ⇒ FileAction
constructor
A new instance of FileAction.
-
#move(params = {}) ⇒ Object
Move file/folder.
-
#status ⇒ Object
string - Status of file operation.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ FileAction
Returns a new instance of FileAction.
7 8 9 10 |
# File 'lib/files.com/models/file_action.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/file_action.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/file_action.rb', line 5 def @options end |
Class Method Details
.begin_upload(path, params = {}, options = {}) ⇒ Object
Begin file upload
Parameters:
mkdir_parents - boolean - Create parent directories if they do not exist?
part - int64 - Part if uploading a part.
parts - int64 - How many parts to fetch?
ref - string -
restart - int64 - File byte offset to restart from.
with_rename - boolean - Allow file rename instead of overwrite?
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/files.com/models/file_action.rb', line 120 def self.begin_upload(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: part must be an Integer") if params.dig(:part) and !params.dig(:part).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: parts must be an Integer") if params.dig(:parts) and !params.dig(:parts).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: ref must be an String") if params.dig(:ref) and !params.dig(:ref).is_a?(String) raise InvalidParameterError.new("Bad parameter: restart must be an Integer") if params.dig(:restart) and !params.dig(:restart).is_a?(Integer) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/file_actions/begin_upload/#{params[:path]}", :post, params, ) response.data.map do |entity_data| FileUploadPart.new(entity_data, ) end end |
.copy(path, params = {}, options = {}) ⇒ Object
Copy file/folder
Parameters:
destination (required) - string - Copy destination path.
structure - boolean - Copy structure only?
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/files.com/models/file_action.rb', line 83 def self.copy(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: destination must be an String") if params.dig(:destination) and !params.dig(:destination).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) raise MissingParameterError.new("Parameter missing: destination") unless params.dig(:destination) response, = Api.send_request("/file_actions/copy/#{params[:path]}", :post, params, ) FileAction.new(response.data, ) end |
.move(path, params = {}, options = {}) ⇒ Object
Move file/folder
Parameters:
destination (required) - string - Move destination path.
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/files.com/models/file_action.rb', line 99 def self.move(path, params = {}, = {}) params ||= {} params[:path] = path raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: destination must be an String") if params.dig(:destination) and !params.dig(:destination).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) raise MissingParameterError.new("Parameter missing: destination") unless params.dig(:destination) response, = Api.send_request("/file_actions/move/#{params[:path]}", :post, params, ) FileAction.new(response.data, ) end |
Instance Method Details
#begin_upload(params = {}) ⇒ Object
Begin file upload
Parameters:
mkdir_parents - boolean - Create parent directories if they do not exist?
part - int64 - Part if uploading a part.
parts - int64 - How many parts to fetch?
ref - string -
restart - int64 - File byte offset to restart from.
with_rename - boolean - Allow file rename instead of overwrite?
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/files.com/models/file_action.rb', line 64 def begin_upload(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: part must be an Integer") if params.dig(:part) and !params.dig(:part).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: parts must be an Integer") if params.dig(:parts) and !params.dig(:parts).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: ref must be an String") if params.dig(:ref) and !params.dig(:ref).is_a?(String) raise InvalidParameterError.new("Bad parameter: restart must be an Integer") if params.dig(:restart) and !params.dig(:restart).is_a?(Integer) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) Api.send_request("/file_actions/begin_upload/#{@attributes[:path]}", :post, params, @options) end |
#copy(params = {}) ⇒ Object
Copy file/folder
Parameters:
destination (required) - string - Copy destination path.
structure - boolean - Copy structure only?
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/files.com/models/file_action.rb', line 27 def copy(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: destination must be an String") if params.dig(:destination) and !params.dig(:destination).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) raise MissingParameterError.new("Parameter missing: destination") unless params.dig(:destination) Api.send_request("/file_actions/copy/#{@attributes[:path]}", :post, params, @options) end |
#file_migration_id ⇒ Object
int64 - If status is enqueued, this is the id of the FileMigration to check for status updates.
18 19 20 |
# File 'lib/files.com/models/file_action.rb', line 18 def file_migration_id @attributes[:file_migration_id] end |
#move(params = {}) ⇒ Object
Move file/folder
Parameters:
destination (required) - string - Move destination path.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/files.com/models/file_action.rb', line 43 def move(params = {}) params ||= {} params[:path] = @attributes[:path] raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path] raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: destination must be an String") if params.dig(:destination) and !params.dig(:destination).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) raise MissingParameterError.new("Parameter missing: destination") unless params.dig(:destination) Api.send_request("/file_actions/move/#{@attributes[:path]}", :post, params, @options) end |
#status ⇒ Object
string - Status of file operation. Possible values: completed, enqueued.
13 14 15 |
# File 'lib/files.com/models/file_action.rb', line 13 def status @attributes[:status] end |