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.
-
#initialize(attributes = {}, options = {}) ⇒ FileAction
constructor
A new instance of FileAction.
-
#move(params = {}) ⇒ Object
Move file/folder.
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?
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/files.com/models/file_action.rb', line 110 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?
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/files.com/models/file_action.rb', line 73 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, ) response.data end |
.move(path, params = {}, options = {}) ⇒ Object
Move file/folder
Parameters:
destination (required) - string - Move destination path.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/files.com/models/file_action.rb', line 89 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, ) 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?
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/files.com/models/file_action.rb', line 54 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?
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/files.com/models/file_action.rb', line 17 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 |
#move(params = {}) ⇒ Object
Move file/folder
Parameters:
destination (required) - string - Move destination path.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/files.com/models/file_action.rb', line 33 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 |