#GET request get '/sample45' do haml :sample45 end #POST request post '/sample45' do #Set variables set :client_id, params[:clientId] set :private_key, params[:privateKey] set :folder_name, params[:folderName] set :file_name, params[:fileName] set :base_path, params[:basePath] begin #Check required variables raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.file_name.empty? #Prepare base path if settings.base_path.empty? base_path = 'https://api.groupdocs.com' elsif settings.base_path.match('/v2.0') base_path = settings.base_path.split('/v2.0')[0] else base_path = settings.base_path end #Configure your access to API server GroupDocs.configure do |groupdocs| groupdocs.client_id = settings.client_id groupdocs.private_key = settings.private_key #Optionally specify API server and version groupdocs.api_server = base_path # default is 'https://api.groupdocs.com' end #Make a request to API using client_id and private_key if settings.folder_name.empty? then files_list = GroupDocs::Storage::Folder.list!('/', {}) else files_list = GroupDocs::Storage::Folder.list!(settings.folder_name + '/', {}) end #Construct list of files result = '' files_list.each do |element| if element.name == settings.file_name #Construct html result file = element.to_document.metadata! result += "
Total document's info:
" result += "Parameter | Info |
page_count | #{file.page_count} |
views_count | #{file.views_count} |
name | #{file.last_view.document.file.name} |
version | #{file.last_view.document.file.version} |
size | #{file.last_view.document.file.size} |
type | #{file.last_view.document.file.type} |
file_type_str | #{file.last_view.document.file.file_type} |
access | #{file.last_view.document.file.access} |
url | #{file.last_view.document.file.url} |
id | #{file.last_view.document.file.id} |
guid | #{file.last_view.document.file.guid} |
short_url | #{file.last_view.short_url} |
viewed_on | #{file.last_view.viewed_on} |