Sha256: 4444d7bd1fb42dcdfea5b60f10a00e53eeddb864ea7e220b2bd4df2b1e3120fa

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 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

1 entries across 1 versions & 1 rubygems

Version Path
groupdocs-2.3.0 examples/viewer/app.rb