class Egnyte::File

Public Class Methods

find(session, path) click to toggle source
# 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

Public Instance Methods

delete() click to toggle source
# File lib/egnyte/file.rb, line 32
def delete
  @session.delete("#{fs_path}#{path}")
end
download() click to toggle source
# File lib/egnyte/file.rb, line 13
def download
  stream.read
end
download_version(entry_id) click to toggle source
# File lib/egnyte/file.rb, line 17
def download_version(entry_id)
  stream(:entry_id => entry_id).read
end
stream( opts={} ) click to toggle source

use opts to provide lambdas to track the streaming download:

:content_length_proc :progress_proc

# 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