Vault OData interface
Copy
The content Vault servers store files. When there is more than one Vault server, each server may be in a different location. All Vault servers have an assigned priority based on the user’s location. For example, if a user in China tries to access a Vault Server also located in China, then that Vault server has priority 1 because of its proximity to the user.
The content Vault server has its own OData interface for uploading file content. This interface exposes the three methods described in the following sections.
The vault.BeginTransaction Method starts the file upload transaction and returns a transaction ID:
POST http://vault/odata/vault.BeginTransaction VAULTID: {{vault_id}} Response: HTTP/1.1 200 OK Content-Type: application/json { “transactionId": “8970e933322d1328537f645d3683214c” }
VAULTID header to the vault.BeginTransaction request. To receive {{vault_id}} value, you need to send the following request:
GET http://host/server/odata/User(‘{{current_user_id}}’)?$select=default_vault Response: { "@odata.context": “http://host/server/odata/$metadata#User(default_vault)/$entity”, "@odata.id": “User({{current_user_id}})”, “default_vault@odata.associationLink": “User('{{current_user_id}}')/default_vault/$ref”, “default_vault@odata.navigationLink": “User('{{current_user_id}}')/default_vault”, “default_vault@aras.keyed_name": “Default”, “default_vault@aras.id": "{{vault_id}}" }
The vault.UploadFile Method uploads the file chunk within a given transaction. The File ID is GUID generated on the client and passed to the vault server using the fileId query option. The upload must use Transfer-encoding: chunked and containing a Content-range header where the range is the range of bytes within the chunk of the file being transferred and the size is the file size. A Content-disposition header must be included containing the name of the file being uploaded.
POST http://vault/odata/vault.UploadFile?fileId=2778F0A17FDF4095A497A9A27B594376 VAULTID: {{vault_id}} Content-Disposition:attachment; filename*=utf-8''file_0.txt Content-Length:53 Content-Range:bytes 0-52/53 Content-Type:application/octet-stream Aras-Content-Range-Checksum:2535782373 Aras-Content-Range-Checksum-Type:xxHashAsUInt32AsDecimalString transactionid:{{transaction_id}} … file chunk content Response: HTTP/1.1 200 OK
VAULTID header to the vault.UploadFile request. To receive {{vault_id}} value, you must send the request as shown in the following example.
GET http://host/server/odata/User(‘{{current_user_id}}’)?$select=default_vault Response: { "@odata.context": “http://host/server/odata/$metadata#User(default_vault)/$entity”, "@odata.id": “User({{current_user_id}})”, “default_vault@odata.associationLink": “User('{{current_user_id}}')/default_vault/$ref”, “default_vault@odata.navigationLink": “User('{{current_user_id}}')/default_vault”, “default_vault@aras.keyed_name": “Default”, “default_vault@aras.id": "{{vault_id}}" }
The vault.CommitTransaction method finalizes a file upload and submits the OData representation of the item using file(s) uploaded by the vault.UploadFile method. This includes the file ID, filename, file size, and the Located item that points to the current user’s vault. For example:
{ ‘id': [id passed to the vault.UploadFile method], ‘filename': [the name of the file being uploaded], ‘file_size': [the size of the file in bytes], ‘located': [ { ‘file_version': [the version of the file], ‘related_id': [the ID of the user’s vault] } ] } Once Aras Innovator responds that the transaction is successful, the Vault server commits the transaction.
POST http://vault/odata/vault.CommitTransaction VAULTID: {{vault_id}} Prefer: return=minimal OData-Version: 4.0 transactionid: 8970e933322d1328537f645d3683214c Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Length: ### --batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: application/http POST /odata/Document HTTP/1.1 Host: host Content-Type: application/json { "@odata.context":"http://host/server/odata/$metadata#Document/$entity” "@odata.type":"#Document”, “id":"FBCC…74FC”, “item_number": “DOC-01", “Document File": [{ “id":"40F1…6369", “related_id": { “id":"2778F0A17FDF4095A497A9A27B594376", “filename": “6d039e86857376a761b87c4d559953e2.jpg” } }] } --batch_36522ad7-fc75-4b56-8c71-56071383e77b-- Response: HTTP/1.1 204 No Content Location: http://host/server/odata/Document(‘FBCC…74FC’)
VAULTID header to the vault.CommitTransaction request. To receive {{vault_id}} value, send the request shown here.
GET http://host/server/odata/User(‘{{current_user_id}}’)?$select=default_vault Response: { "@odata.context": “http://host/server/odata/$metadata#User(default_vault)/$entity”, "@odata.id": “User({{current_user_id}})”, “default_vault@odata.associationLink": “User('{{current_user_id}}')/default_vault/$ref”, “default_vault@odata.navigationLink": “User('{{current_user_id}}')/default_vault”, “default_vault@aras.keyed_name": “Default”, “default_vault@aras.id": "{{vault_id}}" }