Class: Egnyte::File
Instance Attribute Summary
Attributes inherited from Item
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #download ⇒ Object
- #download_version(entry_id) ⇒ Object
-
#stream(opts = {}) ⇒ Object
use opts to provide lambdas to track the streaming download:.
Methods inherited from Item
#copy, fs_path, #fs_path, #initialize, #method_missing, #move, #move_or_copy, #update_data
Constructor Details
This class inherits a constructor from Egnyte::Item
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Egnyte::Item
Class Method Details
.find(session, path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/egnyte/file.rb', line 36 def self.find(session, path) path = Egnyte::Helper.normalize_path(path) file = File.new({ 'path' => path }, session) parsed_body = session.get("#{file.fs_path}#{path}") raise FileExpected if parsed_body['is_folder'] file.update_data(parsed_body) end |
Instance Method Details
#delete ⇒ Object
32 33 34 |
# File 'lib/egnyte/file.rb', line 32 def delete @session.delete("#{fs_path}#{path}") end |
#download ⇒ Object
13 14 15 |
# File 'lib/egnyte/file.rb', line 13 def download stream.read end |
#download_version(entry_id) ⇒ Object
17 18 19 |
# File 'lib/egnyte/file.rb', line 17 def download_version(entry_id) stream(:entry_id => entry_id).read end |
#stream(opts = {}) ⇒ Object
use opts to provide lambdas to track the streaming download:
:content_length_proc :progress_proc
26 27 28 29 30 |
# File 'lib/egnyte/file.rb', line 26 def stream( opts={} ) file_content_path = "#{fs_path('fs-content')}#{Egnyte::Helper.normalize_path(path)}" file_content_path += "?entry_id=#{opts[:entry_id]}" if opts[:entry_id] @session.streaming_download(file_content_path, opts ) end |