Sha256: 02bd97cf916c04cfd8a28c327198f890d52ee819798953388141bd8f82614758

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

get '/sample3' do

  haml :sample3
end

post '/sample3' do
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  begin
    raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
    
    filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
    File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
    file = GroupDocs::Storage::File.upload!(filepath, {}, client_id: settings.client_id, private_key: settings.private_key)
    massage = "<p>File was uploaded to GroupDocs. Here you can see your <strong>#{params[:file][:filename]}</strong> file in the GroupDocs Embedded Viewer.</p>"
    iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/Embed/#{file.guid}' frameborder='0' width='720' height='600'></iframe>"
  
  rescue Exception => e
    err = e.message
  end  
  
  haml :sample3, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :iframe=>iframe, :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/sample3.rb
groupdocs-1.2.7 examples/api-samples/samples/sample3.rb
groupdocs-1.2.6 examples/api-samples/samples/sample3.rb
groupdocs-1.2.3 examples/api-samples/samples/sample3.rb
groupdocs-1.2.2 examples/api-samples/samples/sample3.rb
groupdocs-1.2.1 examples/api-samples/samples/sample3.rb
groupdocs-1.2.0 examples/api-samples/samples/sample3.rb