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 : https://doc.cuba-platform.com/manual-6.5/rest_upload_file.html.

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 : https://doc.cuba-platform.com/manual-6.5/rest_api_v2_ex_get_token.html ?

Also there seems to be an additional way of uploading files into CUBA application : http://files.cuba-platform.com/swagger/#!/Files/post_files

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 (https://doc.cuba-platform.com/manual-6.5/file_upload.html) ?

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.