File upload to storage - how to get session id ?

Hi

I’m writing a script to upload files to our CUBA application file storage. I plan to use the file upload rest api described here : Uploading Files to Storage - CUBA Platform. Developer’s Manual.

So I need to set a session ID in the header but where I should get it from ?

Can I use the OAuth token id I can get like that : Getting an OAuth Token - CUBA Platform. Developer’s Manual ?

Also there seems to be an additional way of uploading files into CUBA application : Swagger UI

Which one should be used ? (and why have two of them)

Mike

Hi, use the one that is described in the swagger file. The first link you posted is for the REST API v1 - it’s still in the platform for old applications that used it before REST API v2 was released. New applications should use REST API v2.

Ok thanks Max. I did go the second way and it works.

Is there a way through REST to upload in temp directory like with FileUploadAPI (Uploading Files - CUBA Platform. Developer’s Manual) ?

No, there are no such methods in REST API. Why do you need it? What is your use case?

The files I upload are just temporary. I read and integrate them in database and then they are not needed anymore. With rest api v2, I need to do the cleaning myself, but that’s not a big deal.