How can we send a file through REST

Posted by mysteryminds on 06-Jan-2016 15:42

Hi All gurus 

I have a small request can someone tell me step by step process to send a file to other location outside Progress.

What I'm  planning to achieve is that to open a file in other location  [e.g: If a user clicks a file in ROLLBASE it has to open at our corporate server location which is outside Rollbase Public Network]

I've been told that we need to use the REST API process to do the operation 
So can someone guide me a step by step process 

So Far what has been done :
I'm able to get the name of the document 
OnClick of a document I have used Javascript (window.open) to open out corporate site 
and also opens the HTML Canvas Application.

WHAT IS PENDING 
1. How to send the Physical File to the Server 
2. Converting the file to open it in our applcation 
3. After manipulation to send back to ROLLBASE and save it

Kindly suggest

All Replies

Posted by Anoop Premachandran on 07-Jan-2016 05:08

Can you explain your usecase ?

What interface does the external server expose to accept the file ?

After manipulation, the server needs to send the file to Rollbase using Rollbase REST API - setBinaryData()

Posted by mysteryminds on 07-Jan-2016 09:13

Anoop

My scenario is quite straight forward

Any user who has permissions to modify a file  can click on the files say  .SVG / FW / PSD / PDF file

.SVG / FW / PSD / PDF  files are stored inside ROLLBASE location

So If has list of files according to the logic every extension has its own URL

e.g: If user clicks on SVG file -->  the file must be opened direct from  xyz.com/.../

if user clicks on PDF File --> the file will be opened from syz.com/.../id=201

All the files will be opened and manupulated online,... ONce the file is saved it will post it via REST back into Rollbase

So far I'm able to to get the links to the files e.g based on the extensions .svg / fw/ psd /pdf  auto links are generated to respective location where it must be opened.

At external location we are using XMLHttpRequest / HTML5 CANVAS  and other respective operations  (BINARY / BLOB)

Posted by Anoop Premachandran on 07-Jan-2016 11:16

You will have to solve CORS issue if you want to make calls from client side (browser) of one application to another.

Assuming you do that, I suggest best way is for Rollbase client side script to call an API on the Server mentioning the Record id and Integration Name of File Field.

In the mthod implementation on that Server, you can use getBInaryData() API to get the File, do all manipulations and then use setBinaryData to upload back the updated File

documentation.progress.com/.../index.html

documentation.progress.com/.../index.html

Posted by mysteryminds on 07-Jan-2016 17:35

Dear Anoop

I do have a understanding how the process has to be - as I have implemented the same in other products but not in ROLLBASE and I'm novice to this... So I need a step by step clarifications for me to implement please

BRIEF PROCESS

------------------------------------

From Rollbase (e.g. Document object)

1. Send the record's ID and object integ to your PDF service (Aspose) through a URL Param, e.g. xyz.com/?record={!id}&object=document_&user=one@xyz.com&pass=test

2. On the PDF side, use getBinary (or some API in the doc) to get the Binary of the file

3. Open the file on PDF editor

4. Do your edits

5. When the user saves, use setBinary to post back the changes to the file using the ID and Object Integ name for the API's parameters

REALITY

-------------------------------------------------------------------------

#1 - Rollbase formula/template field

#2 - this will be on the client server side

before you get to open the file on clientserver, you'll need to use REST API to get the file's contents

#3 - once you have the file, open in the service

#4 - edit

#5 - once the user saves the file on the editor, post back the new file to Rollbase using setBinaryData()

The usual process with RB REST API is:

1. Login,

2. perform api (e.g. getBinaryData)

3. Logout

Posted by Anoop Premachandran on 07-Jan-2016 21:27

Looks Fine.

#1 can be a Server Side Trigger using any of these methods - documentation.progress.com/.../index.html

In any API call, you can pass credentials as Basic Auth Header (then you don't need 3 step process for Login, call API, Logout)

Posted by mysteryminds on 08-Jan-2016 16:41

Well this is what is confusing Anoop

I surely need your guidance please..  A step by step saying

#1 - Rollbase formula/template field  - ------[ WHERE IT MUST BE DONE AND WHAT MUST BE DONE]

#2 - this will be on the client server side before you get to open the file on clientserver, you'll need to use REST API to get the file's contents - [  HOW TO CREATE THAT REST AND WHAT ARE THE STEPS AND HOW TO ]

#3 - once you have the file, open in the service [ WHERE WE MUST START IT AND HOW WE CAN DO IT ]

#4 - edit  [ THIS CAN BE ALREADY DONE]

#5 - once the user saves the file on the editor, post back the new file to Rollbase using setBinaryData() [  HOW THIS WOULD BE DONE BY SENDING BACK TO ROLLBASE AND HOW IT WOULD BE SAVED ]

Posted by Anoop Premachandran on 13-Jan-2016 06:18

#1 - Should be done in a Rollbase Serverside Trigger

#2, #3, #4, #5 - All code to be done in the client Server application. Not sure what technology stack you are suing for this. But most stacks would have http client libraries to make HTTP calls

This thread is closed