Upload

Description

POST /noark5/v1/upload

The POST /noark5/v1/upload or as referred to in the documentation upload operation is the way to upload electronic documents to Documaster Archive. The operation returns an identifier of the uploaded file, which can be used at a later stage to be linked to the Document Version(Dokumentversjon) core object.

In case the uploaded electronic documents are not linked to any Document Version (Dokumentversjon) object for more than 3600 seconds/1 hour, the documents are deleted and cannot be referenced. Uploaded documents are not associated (or available) with the archive structure in any way until a transaction operation is executed associating the electronic document with a Dokumentversjon and associating this new version to a Dokument object.

Uploading files with one account, but linking them to Document Version (Dokumentversjon) using another account will result in an HTTP 500 Server Error returned back from the API.

Request

The request for the operation is the electronic document payload. Uploading the document requires it’s name to be provided in the Content-Disposition header as shown below.

HTTP Request
Field Location Mandatory Type Description
Authorization string access token aquired as part of the authentication call, prefixed with Bearer
Content-Type string content type header, should always be provided as application/octet-stream
X-Documaster-Error-Response-Type string custom header indicating that any error should be reported in JSON format, rather than the standard text format, should always be provided as application/json
Content-Disposition string content disposition header defining that a file is uploaded as an attachment and the name of the file. Note that the format of the header value should be attachment; filename || filename* = {electronic document filename}. When filename* is used, the name should be prefixed by the character set (as an example UTF-8, followed by '' and the URL encoded file name. If filename parameter is used, the name should be using only ASCII symbols
payload bytes bytes of the electronic document uploaded to the archive

      Request

POST https://<documaster-instance>.local.documaster.tech:8083/rms/api/public/noark5/v1/upload HTTP/1.1
Authorization: Bearer {{accessTokenIntegrator}}
Content-Disposition: attachment; filename*=utf-8''simple-export.pdf
Content-Type: application/octet-stream

... byte stream of the simple-export.pdf file ...
// new Noark5Client should have been initialized and the integration should hold a valid access token
// file content should be available in an InputStream (fileStream)

Dokumentfil documentFile = client.upload(fileStream, fileName);
String newlyUploadedDocumentID = documentFile.getId();
// new NoarkClient should have been initialized and the integration should hold a valid access token
// file content should be available in an Stream (fileStream)

Dokumentfil documentFile = client.Upload(fileStream, filename) 
string newlyUploadedDocumentID = documentFile.Id;

Response

Response of the upload contains the ID of the newly uploaded electronic document. The ID is used when creating a Document Version (Dokumentversjon) core entity through the referanseDokumentfil reference.

HTTP Response
Field Location Type Description
Content-Type string content type header, always is application/json
$.id string identifie of the newly uploaded electronic document

      Response

HTTP/1.1 200 OK
Content-Type: application/json
...
{
    "id":"9983"
}