X

Best Practices from Oracle Development's A‑Team

Managing Oracle Documents Cloud Service files via curl commands

 

Oracle Documents Cloud Service allows users to keep their files in the cloud. It allows organizations to centralize their data. This blog post covers how to manage your files from a terminal. It could be a terminal running on your MacBook laptop, Windows desktop, or Linux server. Command-line tools are a simple applications to upload content into the cloud.

I will cover how using curl, a command line tool for transferring data, we could issue HTTP/HTTPS requests that will interact with Oracle Documents Cloud Service REST API File Resource.

 

curl is a free and open software. It supports a range of internet protocols including HTTP, HTTPS, FTP, FTPS, etc. It can be downloaded from http://curl.haxx.se/download.html

The Oracle Documents Cloud Service REST API File Resource documentation is available at: http://docs.oracle.com/cloud/latest/documentcs_welcome/WCCCD/GUID-2A7675E9-536D-47FD-B761-DD1881ADBC7E.htm#WCCCD3763

 

Find below a list of operations allowed on the File Resource:

 

1) Get File Metadata (GET)

FileID for the target document is passed as part of the URLuokiad

curl -u <username>:<password> https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/D7FA6B2DFA043CF6C8F460BAT0000DEFAULT00000000

 

2) Rename File (PUT)

FileID for the target document is passed as part of the URL and the new filename is passed as a JSON argument

curl -u <username>:<password> -X PUT -d "{\"name\":\"renamed_document.pdf\"}" https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/D7FA6B2DFA043CF6C8F460BAT0000DEFAULT00000000

 

3) Copy File (POST)

FileID for the source document is passed as part of the URL and the FolderID for the destination is passed as a JSON argument

curl -u <username>:<password> -X POST -d "{\"destinationID\":\"FD00F625F56050BA15CF567AT0000DEFAULT00000000\"}" https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/D7FA6B2DFA043CF6C8F460BAT0000DEFAULT00000000/copy

 

4) Delete File (DELETE)

FileID for the document to be deleted is passed as part of the URL. Note that this file will be placed in the Trash bin and will not be removed from the system until it is purged from the Trash.

curl -u <username>:<password> -X DELETE https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/D6178E2C7B4ACAE15E179393T0000DEFAULT00000000

 

5) Upload File (POST)

This request passes a two-part multipart/form-data via the -F curl tag: the FolderID for the destination as a JSON argument and the local filename to be uploaded

curl -u <username>:<password> -X POST -F "jsonInputParameters={\"parentID\":\"F5F20CC273D80927A89D0701T0000DEFAULT00000000\"}" -F "primaryFile=@sample_document.pdf" https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/data

 

6) Upload File Version (POST)

FileID for the target document is passed as part of the URL and the new version of the document is passed as a multipart via the curl tag -F

curl -u <username>:<password> -X POST -F "primaryFile=@sample_document.pdf" https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/DE21B5568A9F9A27B16CBA00T0000DEFAULT00000000/data

 

7) Download File (GET)

FileID for the target document is passed as part of the URL

curl -u <username>:<password> https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/D7FA6B2DFA043CF6C8F460BAT0000DEFAULT00000000/data

 

8) Get File Versions (GET)

FileID for the target document is passed as part of the URL

curl -u <username>:<password> https://<ORACLE-DOCS-SERVER>/documents/api/1.1/files/DE21B5568A9F9A27B16CBA00T0000DEFAULT00000000/versions

 

The above operations were tested on a Windows 7 laptop using curl version 7.42.0 (x86_64-pc-win32).

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha