Class: Files::File
- Inherits:
-
Object
- Object
- Files::File
- Defined in:
- lib/files.com/models/file.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
- #lineno(*_args) ⇒ Object
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
- #pos ⇒ Object
- #sync ⇒ Object
Class Method Summary collapse
- .binread(name, *args) ⇒ Object
- .binwrite(name, *args) ⇒ Object
- .chmod(*_args) ⇒ Object
- .chown(*_args) ⇒ Object
- .client(options = {}) ⇒ Object
- .copy(old_path, new_path) ⇒ Object
- .copy_stream(*_args) ⇒ Object
-
.create(path, params = {}, options = {}) ⇒ Object
Upload file.
-
.delete(path, params = {}, options = {}) ⇒ Object
Parameters: recursive - boolean - If true, will recursively delete folers.
- .destroy(path, params = {}, options = {}) ⇒ Object
- .directory?(path, options = {}) ⇒ Boolean
-
.download(path, params = {}, options = {}) ⇒ Object
Download file.
- .download_file(path, local_path = nil) ⇒ Object
- .exist?(path, options = {}) ⇒ Boolean
- .exists?(path, options = {}) ⇒ Boolean
- .find(path, params = {}, options = {}) ⇒ Object
- .for_fd(*_args) ⇒ Object
- .foreach(name, *args, &block) ⇒ Object
- .get(path, params = {}, options = {}) ⇒ Object
- .identical?(path1, path2) ⇒ Boolean
- .lstat(path) ⇒ Object
- .move(old_path, new_path) ⇒ Object
- .mtime(path) ⇒ Object
- .open(path, mode = "r", options = {}, &block) ⇒ Object
- .owned?(_path) ⇒ Boolean
- .pipe(*_args) ⇒ Object
- .popen(*_args) ⇒ Object
- .read(name, *args) ⇒ Object
- .readable?(path) ⇒ Boolean
- .readlines(name, *args) ⇒ Object
- .rename(old_path, new_path) ⇒ Object
- .select(*_args) ⇒ Object
- .stat(path) ⇒ Object
- .sysopen(*_args) ⇒ Object
- .try_convert(*_args) ⇒ Object
- .unlink(*paths) ⇒ Object
-
.update(path, params = {}, options = {}) ⇒ Object
Parameters: provided_mtime - string - Modified time of file.
- .upload_chunks(io, path, options, upload = nil, etags = []) ⇒ Object
- .upload_file(path, destination = nil, options = {}) ⇒ Object
- .write(*_args) ⇒ Object
- .zero?(path) ⇒ Boolean
Instance Method Summary collapse
-
#action ⇒ Object
string - The action to perform.
- #action=(value) ⇒ Object
- #advise(*_args) ⇒ Object
- #atime ⇒ Object
- #autoclose=(*_args) ⇒ Object
- #autoclose?(*_args) ⇒ Boolean
- #binmode ⇒ Object
- #binmode? ⇒ Boolean
- #birthtime ⇒ Object
- #bytes ⇒ Object
- #chars ⇒ Object
- #chmod(*_args) ⇒ Object
- #chown(*_args) ⇒ Object
- #client ⇒ Object
- #close ⇒ Object
- #close_on_exec=(*args) ⇒ Object
- #close_on_exec?(*args) ⇒ Boolean
- #close_read(*args) ⇒ Object
- #close_write(*args) ⇒ Object
- #closed?(*args) ⇒ Boolean
- #codepoints(*args, &block) ⇒ Object
- #copy(destination) ⇒ Object
-
#crc32 ⇒ Object
string - File CRC32 checksum.
- #crc32=(value) ⇒ Object
-
#create(params = {}) ⇒ Object
Upload file.
- #ctime(*_args) ⇒ Object
-
#delete(params = {}) ⇒ Object
Parameters: recursive - boolean - If true, will recursively delete folers.
- #destroy(params = {}) ⇒ Object
-
#display_name ⇒ Object
string - File/Folder display name.
- #display_name=(value) ⇒ Object
-
#download(params = {}) ⇒ Object
Download file.
- #download_content(io) ⇒ Object
- #download_file(output_file) ⇒ Object
-
#download_uri ⇒ Object
string - Link to download file.
- #download_uri=(value) ⇒ Object
- #download_uri_with_load ⇒ Object
- #each(*args, &block) ⇒ Object
- #each_byte(*args, &block) ⇒ Object
- #each_char(*args, &block) ⇒ Object
- #each_codepoint(*args, &block) ⇒ Object
- #each_line(*args, &block) ⇒ Object
- #empty? ⇒ Boolean
- #eof ⇒ Object
- #eof? ⇒ Boolean
- #external_encoding(*args) ⇒ Object
- #fcntl(*_args) ⇒ Object
- #fdatasync(*_args) ⇒ Object
- #fileno(*_args) ⇒ Object
- #flock(*_args) ⇒ Object
- #flush(*_args) ⇒ Object
- #fsync(*args) ⇒ Object
- #getbyte(*args) ⇒ Object
- #getc(*args) ⇒ Object
- #gets(*args) ⇒ Object
-
#id ⇒ Object
int64 - File/Folder ID.
- #id=(value) ⇒ Object
-
#initialize(*args) ⇒ File
constructor
A new instance of File.
- #internal_encoding(*_args) ⇒ Object
- #ioctl(*_args) ⇒ Object
- #isatty(*_args) ⇒ Object
-
#length ⇒ Object
int64 - Length of file.
- #length=(value) ⇒ Object
- #lines(*args, &block) ⇒ Object
- #lstat(*_args) ⇒ Object
-
#md5 ⇒ Object
string - File MD5 checksum.
- #md5=(value) ⇒ Object
-
#mime_type ⇒ Object
string - MIME Type.
- #mime_type=(value) ⇒ Object
-
#mkdir_parents ⇒ Object
boolean - Create parent directories if they do not exist?.
- #mkdir_parents=(value) ⇒ Object
- #move(destination) ⇒ Object
-
#mtime ⇒ Object
date-time - File last modified date/time, according to the server.
- #mtime=(value) ⇒ Object
- #mv(destination) ⇒ Object
-
#part ⇒ Object
int64 - Part if uploading a part.
- #part=(value) ⇒ Object
-
#parts ⇒ Object
int64 - How many parts to fetch?.
- #parts=(value) ⇒ Object
-
#path ⇒ Object
string - File/Folder path This must be slash-delimited, but it must neither start nor end with a slash.
- #path=(value) ⇒ Object
-
#permissions ⇒ Object
string - A short string representing the current user’s permissions.
- #permissions=(value) ⇒ Object
- #pid(*_args) ⇒ Object
- #pread(*args) ⇒ Object
-
#preview ⇒ Object
File preview.
- #preview=(value) ⇒ Object
-
#preview_id ⇒ Object
int64 - File preview ID.
- #preview_id=(value) ⇒ Object
- #print(*args) ⇒ Object
- #printf(*args) ⇒ Object
-
#priority_color ⇒ Object
string - Bookmark/priority color of file/folder.
- #priority_color=(value) ⇒ Object
-
#provided_mtime ⇒ Object
date-time - File last modified date/time, according to the client who set it.
- #provided_mtime=(value) ⇒ Object
- #putc(*args) ⇒ Object
- #puts(*args) ⇒ Object
- #pwrite(*args) ⇒ Object
- #read(*args) ⇒ Object
- #read_io ⇒ Object
- #read_nonblock(*args) ⇒ Object
- #readbyte(*args) ⇒ Object
- #readchar(*args) ⇒ Object
- #readline(*args) ⇒ Object
- #readlines(*args) ⇒ Object
- #readpartial(*args) ⇒ Object
-
#ref ⇒ Object
string -.
- #ref=(value) ⇒ Object
-
#region ⇒ Object
string - Region location.
- #region=(value) ⇒ Object
- #rename(destination) ⇒ Object
- #reopen(*_args) ⇒ Object
-
#restart ⇒ Object
int64 - File byte offset to restart from.
- #restart=(value) ⇒ Object
- #rewind ⇒ Object
- #save ⇒ Object
- #seek(pos) ⇒ Object
-
#set_encoding(*_args) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
-
#size ⇒ Object
int64 - File/Folder size.
- #size=(value) ⇒ Object
- #stat(*_args) ⇒ Object
-
#structure ⇒ Object
string - If copying folder, copy just the structure?.
- #structure=(value) ⇒ Object
- #subfolders_locked=(value) ⇒ Object
-
#subfolders_locked? ⇒ Boolean
boolean - Are subfolders locked and unable to be modified?.
- #sysread(*args) ⇒ Object
- #sysseek(*args) ⇒ Object
- #syswrite(*_args) ⇒ Object
- #tell ⇒ Object
- #to_i(*_args) ⇒ Object
- #to_io(*_args) ⇒ Object
- #to_path(*_args) ⇒ Object
- #truncate(*_args) ⇒ Object
- #tty?(*_args) ⇒ Boolean
-
#type ⇒ Object
string - Type: ‘directory` or `file`.
- #type=(value) ⇒ Object
- #ungetbyte(*_args) ⇒ Object
- #ungetc(*_args) ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: provided_mtime - string - Modified time of file.
- #upload_file(local_file) ⇒ Object
-
#with_rename ⇒ Object
boolean - Allow file rename instead of overwrite?.
- #with_rename=(value) ⇒ Object
- #write(*args) ⇒ Object
- #write_nonblock(*args) ⇒ Object
Constructor Details
#initialize(*args) ⇒ File
Returns a new instance of File.
190 191 192 193 194 195 196 197 198 |
# File 'lib/files.com/models/file.rb', line 190 def initialize(*args) @attributes = (args[0].is_a?(Hash) && args[0]) || {} @options = (args[1].is_a?(Hash) && args[1]) @options ||= (args[2].is_a?(Hash) && args[2]) || {} @attributes[:path] = args[0] if args[0].is_a?(String) @mode = args[1] || 'r' if args[1].is_a?(String) @write_io = StringIO.new @bytes_written = 0 end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/file.rb', line 5 def attributes @attributes end |
#lineno(*_args) ⇒ Object
414 415 416 |
# File 'lib/files.com/models/file.rb', line 414 def lineno(*_args) @lineno ||= 0 end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
6 7 8 |
# File 'lib/files.com/models/file.rb', line 6 def mode @mode end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/file.rb', line 5 def @options end |
#pos ⇒ Object
440 441 442 |
# File 'lib/files.com/models/file.rb', line 440 def pos @pos ||= 0 end |
#sync ⇒ Object
522 523 524 |
# File 'lib/files.com/models/file.rb', line 522 def sync @sync ||= false end |
Class Method Details
.binread(name, *args) ⇒ Object
8 9 10 |
# File 'lib/files.com/models/file.rb', line 8 def self.binread(name, *args) new(name).read(*args) end |
.binwrite(name, *args) ⇒ Object
12 13 14 |
# File 'lib/files.com/models/file.rb', line 12 def self.binwrite(name, *args) new(name).write(*args) end |
.chmod(*_args) ⇒ Object
16 17 18 |
# File 'lib/files.com/models/file.rb', line 16 def self.chmod(*_args) raise NotImplementedError end |
.chown(*_args) ⇒ Object
20 21 22 |
# File 'lib/files.com/models/file.rb', line 20 def self.chown(*_args) raise NotImplementedError end |
.client(options = {}) ⇒ Object
24 25 26 |
# File 'lib/files.com/models/file.rb', line 24 def self.client( = {}) [:client] || ApiClient.active_client end |
.copy(old_path, new_path) ⇒ Object
28 29 30 |
# File 'lib/files.com/models/file.rb', line 28 def self.copy(old_path, new_path) FileAction.copy(old_path, destination: new_path) end |
.copy_stream(*_args) ⇒ Object
32 33 34 |
# File 'lib/files.com/models/file.rb', line 32 def self.copy_stream(*_args) raise NotImplementedError end |
.create(path, params = {}, options = {}) ⇒ Object
Upload file
Parameters:
action - string - The action to perform. Can be `append`, `attachment`, `end`, `upload`, `put`, or may not exist
etags[etag] (required) - array - etag identifier.
etags[part] (required) - array - Part number.
length - integer - Length of file.
mkdir_parents - boolean - Create parent directories if they do not exist?
part - integer - Part if uploading a part.
parts - integer - How many parts to fetch?
provided_mtime - string - User provided modification time.
ref - string -
restart - integer - File byte offset to restart from.
size - integer - Size of file.
structure - string - If copying folder, copy just the structure?
with_rename - boolean - Allow file rename instead of overwrite?
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
# File 'lib/files.com/models/file.rb', line 953 def self.create(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: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: length must be an Integer") if params.dig(:length) and !params.dig(:length).is_a?(Integer) 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: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String) 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 InvalidParameterError.new("Bad parameter: size must be an Integer") if params.dig(:size) and !params.dig(:size).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: structure must be an String") if params.dig(:structure) and !params.dig(:structure).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/files/#{URI.encode_www_form_component(params[:path])}", :post, params, ) File.new(response.data, ) end |
.delete(path, params = {}, options = {}) ⇒ Object
Parameters:
recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders. For legacy reasons, this parameter may also be provided as the HTTP header `Depth: Infinity`
989 990 991 992 993 994 995 996 997 |
# File 'lib/files.com/models/file.rb', line 989 def self.delete(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 MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/files/#{URI.encode_www_form_component(params[:path])}", :delete, params, ) response.data end |
.destroy(path, params = {}, options = {}) ⇒ Object
999 1000 1001 |
# File 'lib/files.com/models/file.rb', line 999 def self.destroy(path, params = {}, = {}) delete(path, params, ) end |
.directory?(path, options = {}) ⇒ Boolean
36 37 38 |
# File 'lib/files.com/models/file.rb', line 36 def self.directory?(path, = {}) find(path, {}, ).type == "directory" end |
.download(path, params = {}, options = {}) ⇒ Object
Download file
Parameters:
action - string - Can be blank, `redirect` or `stat`. If set to `stat`, we will return file information but without a download URL, and without logging a download. If set to `redirect` we will serve a 302 redirect directly to the file. This is used for integrations with Zapier, and is not recommended for most integrations.
id - integer - If provided, lookup the file by id instead of path.
with_previews - boolean - Include file preview information?
with_priority_color - boolean - Include file priority color information?
925 926 927 928 929 930 931 932 933 934 935 |
# File 'lib/files.com/models/file.rb', line 925 def self.download(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: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/files/#{URI.encode_www_form_component(params[:path])}", :get, params, ) File.new(response.data, ) end |
.download_file(path, local_path = nil) ⇒ Object
40 41 42 43 |
# File 'lib/files.com/models/file.rb', line 40 def self.download_file(path, local_path = nil) local_path ||= File.basename(path) new(path).download_file(local_path) end |
.exist?(path, options = {}) ⇒ Boolean
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/files.com/models/file.rb', line 45 def self.exist?(path, = {}) find(path, {}, ) true rescue Error => e if e.code == 404 false else raise e end end |
.exists?(path, options = {}) ⇒ Boolean
56 57 58 |
# File 'lib/files.com/models/file.rb', line 56 def self.exists?(path, = {}) exist?(path, ) end |
.find(path, params = {}, options = {}) ⇒ Object
60 61 62 63 |
# File 'lib/files.com/models/file.rb', line 60 def self.find(path, params = {}, = {}) params[:action] = "stat" download(path, params, ) end |
.for_fd(*_args) ⇒ Object
65 66 67 |
# File 'lib/files.com/models/file.rb', line 65 def self.for_fd(*_args) raise NotImplementedError end |
.foreach(name, *args, &block) ⇒ Object
69 70 71 |
# File 'lib/files.com/models/file.rb', line 69 def self.foreach(name, *args, &block) new(name).each(*args, &block) end |
.get(path, params = {}, options = {}) ⇒ Object
73 74 75 |
# File 'lib/files.com/models/file.rb', line 73 def self.get(path, params = {}, = {}) find(path, params, ) end |
.identical?(path1, path2) ⇒ Boolean
77 78 79 |
# File 'lib/files.com/models/file.rb', line 77 def self.identical?(path1, path2) new(path1).crc32 == new(path2).crc32 end |
.lstat(path) ⇒ Object
81 82 83 |
# File 'lib/files.com/models/file.rb', line 81 def self.lstat(path) new(path).stat end |
.move(old_path, new_path) ⇒ Object
85 86 87 |
# File 'lib/files.com/models/file.rb', line 85 def self.move(old_path, new_path) FileAction.move(old_path, destination: new_path) end |
.mtime(path) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/file.rb', line 89 def self.mtime(path) new(path).mtime end |
.open(path, mode = "r", options = {}, &block) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/files.com/models/file.rb', line 93 def self.open(path, mode = "r", ={}, &block) file = new(path, mode, ) if block yield file file.close end file end |
.owned?(_path) ⇒ Boolean
102 103 104 |
# File 'lib/files.com/models/file.rb', line 102 def self.owned?(_path) raise NotImplementedError end |
.pipe(*_args) ⇒ Object
106 107 108 |
# File 'lib/files.com/models/file.rb', line 106 def self.pipe(*_args) raise NotImplementedError end |
.popen(*_args) ⇒ Object
110 111 112 |
# File 'lib/files.com/models/file.rb', line 110 def self.popen(*_args) raise NotImplementedError end |
.read(name, *args) ⇒ Object
114 115 116 |
# File 'lib/files.com/models/file.rb', line 114 def self.read(name, *args) new(name).read(*args) end |
.readable?(path) ⇒ Boolean
118 119 120 |
# File 'lib/files.com/models/file.rb', line 118 def self.readable?(path) new(path).stat..include?("read") end |
.readlines(name, *args) ⇒ Object
122 123 124 |
# File 'lib/files.com/models/file.rb', line 122 def self.readlines(name, *args) new(name).readlines(*args) end |
.rename(old_path, new_path) ⇒ Object
126 127 128 |
# File 'lib/files.com/models/file.rb', line 126 def self.rename(old_path, new_path) FileAction.move(old_path, destination: new_path) end |
.select(*_args) ⇒ Object
130 131 132 |
# File 'lib/files.com/models/file.rb', line 130 def self.select(*_args) raise NotImplementedError end |
.stat(path) ⇒ Object
134 135 136 |
# File 'lib/files.com/models/file.rb', line 134 def self.stat(path) new(path).stat end |
.sysopen(*_args) ⇒ Object
138 139 140 |
# File 'lib/files.com/models/file.rb', line 138 def self.sysopen(*_args) raise NotImplementedError end |
.try_convert(*_args) ⇒ Object
142 143 144 |
# File 'lib/files.com/models/file.rb', line 142 def self.try_convert(*_args) raise NotImplementedError end |
.unlink(*paths) ⇒ Object
146 147 148 |
# File 'lib/files.com/models/file.rb', line 146 def self.unlink(*paths) paths.map { |p| delete(p) } end |
.update(path, params = {}, options = {}) ⇒ Object
Parameters:
provided_mtime - string - Modified time of file.
priority_color - string - Priority/Bookmark color of file.
975 976 977 978 979 980 981 982 983 984 985 |
# File 'lib/files.com/models/file.rb', line 975 def self.update(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: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String) raise InvalidParameterError.new("Bad parameter: priority_color must be an String") if params.dig(:priority_color) and !params.dig(:priority_color).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) response, = Api.send_request("/files/#{URI.encode_www_form_component(params[:path])}", :patch, params, ) File.new(response.data, ) end |
.upload_chunks(io, path, options, upload = nil, etags = []) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/files.com/models/file.rb', line 150 def self.upload_chunks(io, path, , upload = nil, = []) ||= [] bytes_written = 0 loop do upload = FileAction.begin_upload(path, { ref: upload&.ref, part: (upload&.part_number || 0) + 1 }, ) buf = io.read(upload.partsize) || "" bytes_written += buf.length method = upload.http_method.downcase.to_sym response = client().remote_request(method, upload.upload_uri, { "Content-Length": buf.length.to_s }, buf) << { etag: response.headers["ETag"], part: upload.part_number } return upload, , bytes_written if io.eof? end end |
.upload_file(path, destination = nil, options = {}) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/files.com/models/file.rb', line 164 def self.upload_file(path, destination = nil, = {}) local_file = ::File.open(path, 'r') destination ||= File.basename(path) upload, = upload_chunks(local_file, destination, ) params = { action: "end", etags: , provided_mtime: local_file.mtime.to_s, ref: upload.ref, size: local_file.size } create(destination, params, ) ensure local_file.close end |
.write(*_args) ⇒ Object
182 183 184 |
# File 'lib/files.com/models/file.rb', line 182 def self.write(*_args) raise NotImplementedError end |
.zero?(path) ⇒ Boolean
186 187 188 |
# File 'lib/files.com/models/file.rb', line 186 def self.zero?(path) new(path).empty? end |
Instance Method Details
#action ⇒ Object
string - The action to perform. Can be ‘append`, `attachment`, `end`, `upload`, `put`, or may not exist
744 745 746 |
# File 'lib/files.com/models/file.rb', line 744 def action @attributes[:action] end |
#action=(value) ⇒ Object
748 749 750 |
# File 'lib/files.com/models/file.rb', line 748 def action=(value) @attributes[:action] = value end |
#advise(*_args) ⇒ Object
200 |
# File 'lib/files.com/models/file.rb', line 200 def advise(*_args); end |
#atime ⇒ Object
202 203 204 |
# File 'lib/files.com/models/file.rb', line 202 def atime mtime end |
#autoclose=(*_args) ⇒ Object
206 |
# File 'lib/files.com/models/file.rb', line 206 def autoclose=(*_args); end |
#autoclose?(*_args) ⇒ Boolean
208 |
# File 'lib/files.com/models/file.rb', line 208 def autoclose?(*_args); end |
#binmode ⇒ Object
210 211 212 |
# File 'lib/files.com/models/file.rb', line 210 def binmode binmode? end |
#binmode? ⇒ Boolean
214 215 216 |
# File 'lib/files.com/models/file.rb', line 214 def binmode? true end |
#birthtime ⇒ Object
218 219 220 |
# File 'lib/files.com/models/file.rb', line 218 def birthtime raise NotImplementedError end |
#bytes ⇒ Object
222 223 224 |
# File 'lib/files.com/models/file.rb', line 222 def bytes read_io.bytes end |
#chars ⇒ Object
226 227 228 |
# File 'lib/files.com/models/file.rb', line 226 def chars read_io.chars end |
#chmod(*_args) ⇒ Object
230 231 232 |
# File 'lib/files.com/models/file.rb', line 230 def chmod(*_args) raise NotImplementedError end |
#chown(*_args) ⇒ Object
234 235 236 |
# File 'lib/files.com/models/file.rb', line 234 def chown(*_args) raise NotImplementedError end |
#client ⇒ Object
238 239 240 |
# File 'lib/files.com/models/file.rb', line 238 def client [:client] || ApiClient.active_client end |
#close ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/files.com/models/file.rb', line 242 def close flush if @upload = { "action": "end", "etags": @etags, "provided_mtime": Time.now.to_s, "ref": @upload.ref, "size": @bytes_written } file = File.create(path, , @options) @attributes = file.attributes @upload = nil end @write_io.close end |
#close_on_exec=(*args) ⇒ Object
265 266 267 |
# File 'lib/files.com/models/file.rb', line 265 def close_on_exec=(*args) @write_io.close_on_exec = *args end |
#close_on_exec?(*args) ⇒ Boolean
261 262 263 |
# File 'lib/files.com/models/file.rb', line 261 def close_on_exec?(*args) @write_io.close_on_exec? *args end |
#close_read(*args) ⇒ Object
269 270 271 |
# File 'lib/files.com/models/file.rb', line 269 def close_read(*args) @write_io.close_read *args end |
#close_write(*args) ⇒ Object
273 274 275 |
# File 'lib/files.com/models/file.rb', line 273 def close_write(*args) @write_io.close_write *args end |
#closed?(*args) ⇒ Boolean
277 278 279 |
# File 'lib/files.com/models/file.rb', line 277 def closed?(*args) @write_io.closed? *args end |
#codepoints(*args, &block) ⇒ Object
281 282 283 |
# File 'lib/files.com/models/file.rb', line 281 def codepoints(*args, &block) @write_io.codepoints *args, &block end |
#copy(destination) ⇒ Object
285 286 287 |
# File 'lib/files.com/models/file.rb', line 285 def copy(destination) File.copy(path, destination) end |
#crc32 ⇒ Object
string - File CRC32 checksum. This is sometimes delayed, so if you get a blank response, wait and try again.
654 655 656 |
# File 'lib/files.com/models/file.rb', line 654 def crc32 @attributes[:crc32] end |
#crc32=(value) ⇒ Object
658 659 660 |
# File 'lib/files.com/models/file.rb', line 658 def crc32=(value) @attributes[:crc32] = value end |
#create(params = {}) ⇒ Object
Upload file
Parameters:
action - string - The action to perform. Can be `append`, `attachment`, `end`, `upload`, `put`, or may not exist
etags[etag] (required) - array - etag identifier.
etags[part] (required) - array - Part number.
length - integer - Length of file.
mkdir_parents - boolean - Create parent directories if they do not exist?
part - integer - Part if uploading a part.
parts - integer - How many parts to fetch?
provided_mtime - string - User provided modification time.
ref - string -
restart - integer - File byte offset to restart from.
size - integer - Size of file.
structure - string - If copying folder, copy just the structure?
with_rename - boolean - Allow file rename instead of overwrite?
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/files.com/models/file.rb', line 859 def create(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: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: length must be an Integer") if params.dig(:length) and !params.dig(:length).is_a?(Integer) 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: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String) 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 InvalidParameterError.new("Bad parameter: size must be an Integer") if params.dig(:size) and !params.dig(:size).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: structure must be an String") if params.dig(:structure) and !params.dig(:structure).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) Api.send_request("/files/#{Addressable::URI.encode_component(params[:path])}", :post, params, @options) end |
#ctime(*_args) ⇒ Object
289 290 291 |
# File 'lib/files.com/models/file.rb', line 289 def ctime(*_args) mtime end |
#delete(params = {}) ⇒ Object
Parameters:
recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders. For legacy reasons, this parameter may also be provided as the HTTP header `Depth: Infinity`
895 896 897 898 899 900 901 902 903 |
# File 'lib/files.com/models/file.rb', line 895 def delete(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 MissingParameterError.new("Parameter missing: path") unless params.dig(:path) Api.send_request("/files/#{Addressable::URI.encode_component(params[:path])}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
905 906 907 |
# File 'lib/files.com/models/file.rb', line 905 def destroy(params = {}) delete(params) end |
#display_name ⇒ Object
string - File/Folder display name
609 610 611 |
# File 'lib/files.com/models/file.rb', line 609 def display_name @attributes[:display_name] end |
#display_name=(value) ⇒ Object
613 614 615 |
# File 'lib/files.com/models/file.rb', line 613 def display_name=(value) @attributes[:display_name] = value end |
#download(params = {}) ⇒ Object
Download file
Parameters:
action - string - Can be blank, `redirect` or `stat`. If set to `stat`, we will return file information but without a download URL, and without logging a download. If set to `redirect` we will serve a 302 redirect directly to the file. This is used for integrations with Zapier, and is not recommended for most integrations.
id - integer - If provided, lookup the file by id instead of path.
with_previews - boolean - Include file preview information?
with_priority_color - boolean - Include file priority color information?
831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/files.com/models/file.rb', line 831 def download(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: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) Api.send_request("/files/#{Addressable::URI.encode_component(params[:path])}", :get, params, @options) end |
#download_content(io) ⇒ Object
307 308 309 |
# File 'lib/files.com/models/file.rb', line 307 def download_content(io) Files::ApiClient::download_client.stream_download(download_uri_with_load, io) end |
#download_file(output_file) ⇒ Object
301 302 303 304 305 |
# File 'lib/files.com/models/file.rb', line 301 def download_file(output_file) ::File.open(output_file, 'wb') do |file| download_content(file) end end |
#download_uri ⇒ Object
string - Link to download file. Provided only in response to a download request.
708 709 710 |
# File 'lib/files.com/models/file.rb', line 708 def download_uri @attributes[:download_uri] end |
#download_uri=(value) ⇒ Object
712 713 714 |
# File 'lib/files.com/models/file.rb', line 712 def download_uri=(value) @attributes[:download_uri] = value end |
#download_uri_with_load ⇒ Object
293 294 295 296 297 298 299 |
# File 'lib/files.com/models/file.rb', line 293 def download_uri_with_load return download_uri if download_uri file = File.download(path, {}, @options) @attributes = file.attributes download_uri end |
#each(*args, &block) ⇒ Object
311 312 313 |
# File 'lib/files.com/models/file.rb', line 311 def each(*args, &block) read_io.each *args, &block end |
#each_byte(*args, &block) ⇒ Object
315 316 317 |
# File 'lib/files.com/models/file.rb', line 315 def each_byte(*args, &block) read_io.each_byte *args, &block end |
#each_char(*args, &block) ⇒ Object
319 320 321 |
# File 'lib/files.com/models/file.rb', line 319 def each_char(*args, &block) read_io.each_char *args, &block end |
#each_codepoint(*args, &block) ⇒ Object
323 324 325 |
# File 'lib/files.com/models/file.rb', line 323 def each_codepoint(*args, &block) read_io.each_codepoint *args, &block end |
#each_line(*args, &block) ⇒ Object
327 328 329 |
# File 'lib/files.com/models/file.rb', line 327 def each_line(*args, &block) each(*args, &block) end |
#empty? ⇒ Boolean
331 332 333 |
# File 'lib/files.com/models/file.rb', line 331 def empty? size == 0 end |
#eof ⇒ Object
335 336 337 |
# File 'lib/files.com/models/file.rb', line 335 def eof eof? end |
#eof? ⇒ Boolean
339 340 341 |
# File 'lib/files.com/models/file.rb', line 339 def eof? @write_io.eof? end |
#external_encoding(*args) ⇒ Object
343 344 345 |
# File 'lib/files.com/models/file.rb', line 343 def external_encoding(*args) internal_encoding *args end |
#fcntl(*_args) ⇒ Object
347 348 349 |
# File 'lib/files.com/models/file.rb', line 347 def fcntl(*_args) raise NotImplementedError end |
#fdatasync(*_args) ⇒ Object
351 352 353 |
# File 'lib/files.com/models/file.rb', line 351 def fdatasync(*_args) flush end |
#fileno(*_args) ⇒ Object
355 356 357 |
# File 'lib/files.com/models/file.rb', line 355 def fileno(*_args) id end |
#flock(*_args) ⇒ Object
359 360 361 |
# File 'lib/files.com/models/file.rb', line 359 def flock(*_args) raise NotImplementedError end |
#flush(*_args) ⇒ Object
363 364 365 366 367 368 369 370 371 372 |
# File 'lib/files.com/models/file.rb', line 363 def flush(*_args) if mode.include? "w" @write_io.rewind if @write_io.is_a?(StringIO) @upload, @etags, bytes_written = File.upload_chunks(@write_io, path, , @upload, @etags) @bytes_written += bytes_written elsif mode.include? "a" raise NotImplementedError end end |
#fsync(*args) ⇒ Object
374 375 376 |
# File 'lib/files.com/models/file.rb', line 374 def fsync(*args) flush *args end |
#getbyte(*args) ⇒ Object
378 379 380 |
# File 'lib/files.com/models/file.rb', line 378 def getbyte(*args) read_io.getbyte *args end |
#getc(*args) ⇒ Object
382 383 384 |
# File 'lib/files.com/models/file.rb', line 382 def getc(*args) read_io.getc *args end |
#gets(*args) ⇒ Object
386 387 388 |
# File 'lib/files.com/models/file.rb', line 386 def gets(*args) read_io.gets *args end |
#id ⇒ Object
int64 - File/Folder ID
591 592 593 |
# File 'lib/files.com/models/file.rb', line 591 def id @attributes[:id] end |
#id=(value) ⇒ Object
595 596 597 |
# File 'lib/files.com/models/file.rb', line 595 def id=(value) @attributes[:id] = value end |
#internal_encoding(*_args) ⇒ Object
402 403 404 |
# File 'lib/files.com/models/file.rb', line 402 def internal_encoding(*_args) "".encoding end |
#ioctl(*_args) ⇒ Object
406 407 408 |
# File 'lib/files.com/models/file.rb', line 406 def ioctl(*_args) raise NotImplementedError end |
#isatty(*_args) ⇒ Object
410 411 412 |
# File 'lib/files.com/models/file.rb', line 410 def isatty(*_args) false end |
#length ⇒ Object
int64 - Length of file.
753 754 755 |
# File 'lib/files.com/models/file.rb', line 753 def length @attributes[:length] end |
#length=(value) ⇒ Object
757 758 759 |
# File 'lib/files.com/models/file.rb', line 757 def length=(value) @attributes[:length] = value end |
#lines(*args, &block) ⇒ Object
420 421 422 |
# File 'lib/files.com/models/file.rb', line 420 def lines(*args, &block) each_line *args, &block end |
#lstat(*_args) ⇒ Object
424 425 426 |
# File 'lib/files.com/models/file.rb', line 424 def lstat(*_args) stats end |
#md5 ⇒ Object
string - File MD5 checksum. This is sometimes delayed, so if you get a blank response, wait and try again.
663 664 665 |
# File 'lib/files.com/models/file.rb', line 663 def md5 @attributes[:md5] end |
#md5=(value) ⇒ Object
667 668 669 |
# File 'lib/files.com/models/file.rb', line 667 def md5=(value) @attributes[:md5] = value end |
#mime_type ⇒ Object
string - MIME Type. This is determined by the filename extension and is not stored separately internally.
672 673 674 |
# File 'lib/files.com/models/file.rb', line 672 def mime_type @attributes[:mime_type] end |
#mime_type=(value) ⇒ Object
676 677 678 |
# File 'lib/files.com/models/file.rb', line 676 def mime_type=(value) @attributes[:mime_type] = value end |
#mkdir_parents ⇒ Object
boolean - Create parent directories if they do not exist?
762 763 764 |
# File 'lib/files.com/models/file.rb', line 762 def mkdir_parents @attributes[:mkdir_parents] end |
#mkdir_parents=(value) ⇒ Object
766 767 768 |
# File 'lib/files.com/models/file.rb', line 766 def mkdir_parents=(value) @attributes[:mkdir_parents] = value end |
#move(destination) ⇒ Object
428 429 430 |
# File 'lib/files.com/models/file.rb', line 428 def move(destination) File.move(path, destination) end |
#mtime ⇒ Object
date-time - File last modified date/time, according to the server. This is the timestamp of the last Files.com operation of the file, regardless of what modified timestamp was sent.
636 637 638 |
# File 'lib/files.com/models/file.rb', line 636 def mtime @attributes[:mtime] end |
#mtime=(value) ⇒ Object
640 641 642 |
# File 'lib/files.com/models/file.rb', line 640 def mtime=(value) @attributes[:mtime] = value end |
#mv(destination) ⇒ Object
432 433 434 |
# File 'lib/files.com/models/file.rb', line 432 def mv(destination) File.move(path, destination) end |
#part ⇒ Object
int64 - Part if uploading a part.
771 772 773 |
# File 'lib/files.com/models/file.rb', line 771 def part @attributes[:part] end |
#part=(value) ⇒ Object
775 776 777 |
# File 'lib/files.com/models/file.rb', line 775 def part=(value) @attributes[:part] = value end |
#parts ⇒ Object
int64 - How many parts to fetch?
780 781 782 |
# File 'lib/files.com/models/file.rb', line 780 def parts @attributes[:parts] end |
#parts=(value) ⇒ Object
784 785 786 |
# File 'lib/files.com/models/file.rb', line 784 def parts=(value) @attributes[:parts] = value end |
#path ⇒ Object
string - File/Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
600 601 602 |
# File 'lib/files.com/models/file.rb', line 600 def path @attributes[:path] end |
#path=(value) ⇒ Object
604 605 606 |
# File 'lib/files.com/models/file.rb', line 604 def path=(value) @attributes[:path] = value end |
#permissions ⇒ Object
string - A short string representing the current user’s permissions. Can be ‘r`,`w`,`p`, or any combination
690 691 692 |
# File 'lib/files.com/models/file.rb', line 690 def @attributes[:permissions] end |
#permissions=(value) ⇒ Object
694 695 696 |
# File 'lib/files.com/models/file.rb', line 694 def (value) @attributes[:permissions] = value end |
#pid(*_args) ⇒ Object
436 437 438 |
# File 'lib/files.com/models/file.rb', line 436 def pid(*_args) Process.pid end |
#pread(*args) ⇒ Object
446 447 448 |
# File 'lib/files.com/models/file.rb', line 446 def pread(*args) read_io.pread *args end |
#preview ⇒ Object
File preview
735 736 737 |
# File 'lib/files.com/models/file.rb', line 735 def preview @attributes[:preview] end |
#preview=(value) ⇒ Object
739 740 741 |
# File 'lib/files.com/models/file.rb', line 739 def preview=(value) @attributes[:preview] = value end |
#preview_id ⇒ Object
int64 - File preview ID
726 727 728 |
# File 'lib/files.com/models/file.rb', line 726 def preview_id @attributes[:preview_id] end |
#preview_id=(value) ⇒ Object
730 731 732 |
# File 'lib/files.com/models/file.rb', line 730 def preview_id=(value) @attributes[:preview_id] = value end |
#print(*args) ⇒ Object
450 451 452 |
# File 'lib/files.com/models/file.rb', line 450 def print(*args) @write_io.print *args end |
#printf(*args) ⇒ Object
454 455 456 |
# File 'lib/files.com/models/file.rb', line 454 def printf(*args) @write_io.printf *args end |
#priority_color ⇒ Object
string - Bookmark/priority color of file/folder
717 718 719 |
# File 'lib/files.com/models/file.rb', line 717 def priority_color @attributes[:priority_color] end |
#priority_color=(value) ⇒ Object
721 722 723 |
# File 'lib/files.com/models/file.rb', line 721 def priority_color=(value) @attributes[:priority_color] = value end |
#provided_mtime ⇒ Object
date-time - File last modified date/time, according to the client who set it. Files.com allows desktop, FTP, SFTP, and WebDAV clients to set modified at times. This allows Desktop<->Cloud syncing to preserve modified at times.
645 646 647 |
# File 'lib/files.com/models/file.rb', line 645 def provided_mtime @attributes[:provided_mtime] end |
#provided_mtime=(value) ⇒ Object
649 650 651 |
# File 'lib/files.com/models/file.rb', line 649 def provided_mtime=(value) @attributes[:provided_mtime] = value end |
#putc(*args) ⇒ Object
458 459 460 |
# File 'lib/files.com/models/file.rb', line 458 def putc(*args) @write_io.putc *args end |
#puts(*args) ⇒ Object
462 463 464 |
# File 'lib/files.com/models/file.rb', line 462 def puts(*args) @write_io.puts *args end |
#pwrite(*args) ⇒ Object
466 467 468 |
# File 'lib/files.com/models/file.rb', line 466 def pwrite(*args) @write_io.pwrite *args end |
#read(*args) ⇒ Object
470 471 472 |
# File 'lib/files.com/models/file.rb', line 470 def read(*args) read_io.read *args end |
#read_io ⇒ Object
390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/files.com/models/file.rb', line 390 def read_io @read_io ||= begin r, w = IO.pipe Thread.new do download_content(w) ensure w.close end r end end |
#read_nonblock(*args) ⇒ Object
474 475 476 |
# File 'lib/files.com/models/file.rb', line 474 def read_nonblock(*args) read_io.read_nonblock *args end |
#readbyte(*args) ⇒ Object
478 479 480 |
# File 'lib/files.com/models/file.rb', line 478 def readbyte(*args) read_io.readbyte *args end |
#readchar(*args) ⇒ Object
482 483 484 |
# File 'lib/files.com/models/file.rb', line 482 def readchar(*args) read_io.readchar *args end |
#readline(*args) ⇒ Object
486 487 488 |
# File 'lib/files.com/models/file.rb', line 486 def readline(*args) read_io.readline *args end |
#readlines(*args) ⇒ Object
490 491 492 |
# File 'lib/files.com/models/file.rb', line 490 def readlines(*args) io.readlines(*args) end |
#readpartial(*args) ⇒ Object
494 495 496 |
# File 'lib/files.com/models/file.rb', line 494 def readpartial(*args) read_io.readpartial *args end |
#ref ⇒ Object
string -
789 790 791 |
# File 'lib/files.com/models/file.rb', line 789 def ref @attributes[:ref] end |
#ref=(value) ⇒ Object
793 794 795 |
# File 'lib/files.com/models/file.rb', line 793 def ref=(value) @attributes[:ref] = value end |
#region ⇒ Object
string - Region location
681 682 683 |
# File 'lib/files.com/models/file.rb', line 681 def region @attributes[:region] end |
#region=(value) ⇒ Object
685 686 687 |
# File 'lib/files.com/models/file.rb', line 685 def region=(value) @attributes[:region] = value end |
#rename(destination) ⇒ Object
498 499 500 |
# File 'lib/files.com/models/file.rb', line 498 def rename(destination) File.rename(path, destination) end |
#reopen(*_args) ⇒ Object
502 503 504 |
# File 'lib/files.com/models/file.rb', line 502 def reopen(*_args) raise NotImplementedError end |
#restart ⇒ Object
int64 - File byte offset to restart from.
798 799 800 |
# File 'lib/files.com/models/file.rb', line 798 def restart @attributes[:restart] end |
#restart=(value) ⇒ Object
802 803 804 |
# File 'lib/files.com/models/file.rb', line 802 def restart=(value) @attributes[:restart] = value end |
#rewind ⇒ Object
506 507 508 |
# File 'lib/files.com/models/file.rb', line 506 def rewind @pos = 0 end |
#save ⇒ Object
909 910 911 912 913 914 915 916 |
# File 'lib/files.com/models/file.rb', line 909 def save if @attributes[:path] update(@attributes) else new_obj = File.create(@attributes, @options) @attributes = new_obj.attributes end end |
#seek(pos) ⇒ Object
510 511 512 |
# File 'lib/files.com/models/file.rb', line 510 def seek(pos) @pos = pos end |
#set_encoding(*_args) ⇒ Object
rubocop:disable Naming/AccessorMethodName
514 515 516 |
# File 'lib/files.com/models/file.rb', line 514 def set_encoding(*_args) # rubocop:disable Naming/AccessorMethodName raise NotImplementedError end |
#size ⇒ Object
int64 - File/Folder size
627 628 629 |
# File 'lib/files.com/models/file.rb', line 627 def size @attributes[:size] end |
#size=(value) ⇒ Object
631 632 633 |
# File 'lib/files.com/models/file.rb', line 631 def size=(value) @attributes[:size] = value end |
#stat(*_args) ⇒ Object
518 519 520 |
# File 'lib/files.com/models/file.rb', line 518 def stat(*_args) stats end |
#structure ⇒ Object
string - If copying folder, copy just the structure?
807 808 809 |
# File 'lib/files.com/models/file.rb', line 807 def structure @attributes[:structure] end |
#structure=(value) ⇒ Object
811 812 813 |
# File 'lib/files.com/models/file.rb', line 811 def structure=(value) @attributes[:structure] = value end |
#subfolders_locked=(value) ⇒ Object
703 704 705 |
# File 'lib/files.com/models/file.rb', line 703 def subfolders_locked=(value) @attributes[:subfolders_locked?] = value end |
#subfolders_locked? ⇒ Boolean
boolean - Are subfolders locked and unable to be modified?
699 700 701 |
# File 'lib/files.com/models/file.rb', line 699 def subfolders_locked? @attributes[:subfolders_locked?] end |
#sysread(*args) ⇒ Object
528 529 530 |
# File 'lib/files.com/models/file.rb', line 528 def sysread(*args) read *args end |
#sysseek(*args) ⇒ Object
532 533 534 |
# File 'lib/files.com/models/file.rb', line 532 def sysseek(*args) seek *args end |
#syswrite(*_args) ⇒ Object
536 537 538 |
# File 'lib/files.com/models/file.rb', line 536 def syswrite(*_args) raise NotImplementedError end |
#tell ⇒ Object
540 541 542 |
# File 'lib/files.com/models/file.rb', line 540 def tell pos end |
#to_i(*_args) ⇒ Object
544 545 546 |
# File 'lib/files.com/models/file.rb', line 544 def to_i(*_args) fileno end |
#to_io(*_args) ⇒ Object
548 549 550 |
# File 'lib/files.com/models/file.rb', line 548 def to_io(*_args) @write_io end |
#to_path(*_args) ⇒ Object
552 553 554 |
# File 'lib/files.com/models/file.rb', line 552 def to_path(*_args) path end |
#truncate(*_args) ⇒ Object
556 557 558 |
# File 'lib/files.com/models/file.rb', line 556 def truncate(*_args) raise NotImplementedError end |
#tty?(*_args) ⇒ Boolean
560 561 562 |
# File 'lib/files.com/models/file.rb', line 560 def tty?(*_args) false end |
#type ⇒ Object
string - Type: ‘directory` or `file`.
618 619 620 |
# File 'lib/files.com/models/file.rb', line 618 def type @attributes[:type] end |
#type=(value) ⇒ Object
622 623 624 |
# File 'lib/files.com/models/file.rb', line 622 def type=(value) @attributes[:type] = value end |
#ungetbyte(*_args) ⇒ Object
564 565 566 |
# File 'lib/files.com/models/file.rb', line 564 def ungetbyte(*_args) raise NotImplementedError end |
#ungetc(*_args) ⇒ Object
568 569 570 |
# File 'lib/files.com/models/file.rb', line 568 def ungetc(*_args) raise NotImplementedError end |
#update(params = {}) ⇒ Object
Parameters:
provided_mtime - string - Modified time of file.
priority_color - string - Priority/Bookmark color of file.
881 882 883 884 885 886 887 888 889 890 891 |
# File 'lib/files.com/models/file.rb', line 881 def update(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: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String) raise InvalidParameterError.new("Bad parameter: priority_color must be an String") if params.dig(:priority_color) and !params.dig(:priority_color).is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path) Api.send_request("/files/#{Addressable::URI.encode_component(params[:path])}", :patch, params, @options) end |
#upload_file(local_file) ⇒ Object
572 573 574 |
# File 'lib/files.com/models/file.rb', line 572 def upload_file(local_file) File.upload_file(local_file. path) end |
#with_rename ⇒ Object
boolean - Allow file rename instead of overwrite?
816 817 818 |
# File 'lib/files.com/models/file.rb', line 816 def with_rename @attributes[:with_rename] end |
#with_rename=(value) ⇒ Object
820 821 822 |
# File 'lib/files.com/models/file.rb', line 820 def with_rename=(value) @attributes[:with_rename] = value end |
#write(*args) ⇒ Object
576 577 578 579 580 581 582 583 584 |
# File 'lib/files.com/models/file.rb', line 576 def write(*args) @mode ||= 'w' if args[0].respond_to?(:read) flush if @write_io.size > 0 @write_io = args[0] else @write_io.write *args end end |
#write_nonblock(*args) ⇒ Object
586 587 588 |
# File 'lib/files.com/models/file.rb', line 586 def write_nonblock(*args) @write_io.write_nonblock *args end |