Sha256: 9ee49526a8745b9c57f993e53d037b372454a1044353b7eaa14d9804cb09a37a

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

get '/sample4' do
  haml :sample4
end

post '/sample4' do
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  set :file_id, params[:file_id]
  begin
    raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty? or settings.file_id.empty?
    
    files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
    dowload_file = ''

    files_list.each do |element|
      if element.id == Integer(settings.file_id)
        dowload_file = element
      end
    end

    dowloaded_file = dowload_file.download!(File.dirname(__FILE__), { :client_id => settings.client_id, :private_key => settings.private_key})
    unless dowloaded_file.empty?
      massage = "<font color='green'>File was downloaded to the <font color='blue'>#{dowloaded_file}</font> folder</font> <br />"
    end

  rescue Exception => e
    err = e.message
  end  
  
  haml :sample4, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :file_id => settings.file_id, :massage => massage, :err => err }
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
groupdocs-1.2.8 examples/api-samples/samples/sample4.rb
groupdocs-1.2.7 examples/api-samples/samples/sample4.rb
groupdocs-1.2.6 examples/api-samples/samples/sample4.rb
groupdocs-1.2.3 examples/api-samples/samples/sample4.rb
groupdocs-1.2.2 examples/api-samples/samples/sample4.rb
groupdocs-1.2.1 examples/api-samples/samples/sample4.rb
groupdocs-1.2.0 examples/api-samples/samples/sample4.rb