Sha256: e9f9df2e258f932ec7c21ee971359a9c93c5cb40c4ceba3cbc6392a77dd8753b

Contents?: true

Size: 745 Bytes

Versions: 4

Compression:

Stored size: 745 Bytes

Contents

module Egnyte
  class File < Item

    def download
      stream.read
    end

    # use opts to provide lambdas
    # to track the streaming download:
    #
    # :content_length_proc
    # :progress_proc
    def stream( opts={} )
      @session.streaming_download( "#{fs_path('fs-content')}/#{URI.escape(path)}", opts )
    end

    def delete
      @session.delete("#{fs_path}/#{URI.escape(path)}")
    end

    def self.find(session, path)
      path = Egnyte::Helper.normalize_path(path)

      file = File.new({
        'path' => path
      }, session)
      
      parsed_body = session.get("#{file.fs_path}#{URI.escape(path)}")

      raise FileExpected if parsed_body['is_folder']

      file.update_data(parsed_body)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
egnyte-1.0.0 lib/egnyte/file.rb
egnyte-0.1.0 lib/egnyte/file.rb
egnyte-0.0.5 lib/egnyte/file.rb
egnyte-0.0.1 lib/egnyte/file.rb