Sha256: 91769876709a2deb2a3868f873a34e39e7d77bd9491b7f5c5b669698effad972

Contents?: true

Size: 1.15 KB

Versions: 32

Compression:

Stored size: 1.15 KB

Contents

require 'sinatra'
require 'groupdocs'
require 'haml'

GroupDocs.api_version = '2.0'

get '/' do
  haml :upload
end

post '/upload' do
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  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: options.client_id, private_key: options.private_key)

   haml :viewer
end


__END__

@@layout
%html
  %head
    %title GroupDocs Ruby SDK Viewer Sample App
  %body
    = yield

@@upload
%h4 Upload file
%form{ action: '/upload', method: 'post', enctype: 'multipart/form-data' }
  %label{ for: 'client_id' } GroupDocs Client ID
  %br
  %input{ type: 'text', name: 'client_id' }
  %br
  %label{ for: 'private_key' } GroupDocs Private Key
  %br
  %input{ type: 'text', name: 'private_key' }
  %br
  %label{ for: 'file' } File
  %br
  %input{ type: 'file', name: 'file' }
  %br
  %br
  %input{ type: 'submit', value: 'Upload' }

@@viewer
%iframe{ src: "https://apps.groupdocs.com/document-viewer/Embed/#{@@file.guid}", frameborder: 0, width: 720, height: 600 }
%br
%br

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
groupdocs-2.2.0 examples/viewer/app.rb
groupdocs-2.1.0 examples/viewer/app.rb
groupdocs-2.0.0 examples/viewer/app.rb
groupdocs-1.9.0 examples/viewer/app.rb
groupdocs-1.8.1 examples/viewer/app.rb
groupdocs-1.8.0 examples/viewer/app.rb
groupdocs-1.7.0 examples/viewer/app.rb
groupdocs-1.6.0 examples/viewer/app.rb
groupdocs-1.5.9 examples/viewer/app.rb
groupdocs-1.5.8 examples/viewer/app.rb
groupdocs-1.5.7 examples/viewer/app.rb
groupdocs-1.5.6 examples/viewer/app.rb
groupdocs-1.5.5 examples/viewer/app.rb
groupdocs-1.5.4 examples/viewer/app.rb
groupdocs-1.5.3 examples/viewer/app.rb
groupdocs-1.5.2 examples/viewer/app.rb
groupdocs-1.5.1 examples/viewer/app.rb
groupdocs-1.5.0 examples/viewer/app.rb
groupdocs-1.4.2 examples/viewer/app.rb
groupdocs-1.4.1 examples/viewer/app.rb