Upload or Download Files using API

Anusha_MP
New Contributor II

We are working on uploading and downloading files onto OneStream FileExplorer. It is possible to fetch the encoded file from the FileContents using the SQL Query over the REST API.

Similarly, is it possible to upload the data to the FileExplorer using the REST API?

Any ideas would be much appreciated.

Regards,

Anusha

6 REPLIES 6

sudarshan
New Contributor III

You can try exploring WINSCP library, there a few examples which you can search for.

Anusha_MP
New Contributor II

Can you please provide an example to upload a file to OneStream FileExplorer using WINSCP from an external system?

ChristianW
Valued Contributor

I'm not working with REST API, but

You can upload the files to a harvest folder and then use an extender rule to copy them to the Onestream File Explorer.

Then you can use our Task Scheduler to execute this rule at a predefined interval (or you call the rule using a REST API call).

If you like to download files, this can be done by an extender rule as well, and you can call this rule via the REST API.

I hope this helps, and cheers.

Omkareshwar
Contributor II

Hi Anusha,

Yes, it is possible to upload data to the file explorer using the REST API. 

  • I am assuming you have created a connection with the REST API and are able to stream the response in your code.
  • You then need to convert your response that into a byte array()
  • Create XFFolderEx object. 
  • Then create XFFileInfo
  • then a new instance of XFFile where you pass the file info and your byte array() 
  • Store that XFFile using BRAPI.FileSystem.InsertOrUpdate(si, fileToSave)

You can go through these APIs to understand this whole thing better I have just given a general overview of how you can do what you're trying to achieve. 

Omkareshwar_0-1691590024000.png

 

Also can you elaborate the bold part "We are working on uploading and downloading files onto OneStream FileExplorer. It is possible to fetch the encoded file from the FileContents using the SQL Query over the REST API."

This whole process is a long complex task to code with a lot of moving pieces really difficult to explain the whole process. 

 

 

 

 

Thanks, Omkareshwar
Archetype Consulting

Maybe Anusha is trying to do the REST calls using their database rather than in a BR? Just a guess. If so, this would not be ideal. You can do all this from Business Rules and the .NET languages quite simply and smoothly. Neither WinSCP or SQL are required. I recently did this with Azure/ADLS and it all went very well.

JackLacava
Honored Contributor

Anything doable from REST is documented in the REST Api Guide document, available in the Server & Documentation package in the Platform section of Solution Exchange. Please get it, it's a fairly short document but it lists all the endpoints and what is possible.