Added in version 1.1.0
In this tutorial we explore the ways to upload files to the Documenten API, depending on the file size.
The most relevant component for this tutorial:
docker and docker-compose to host the components locally on your development machine.
See installatie en configuratie for a detailed description.The main resource of DRC API is EnkelvoudigInformatieObject which supports
creating and editing documents. Its content can be divided into metadata
(identificatie, creatiedatum, titel and etc) and file content. The main
metadata of file content used by the DRC is the file size derived from the
bestandsomvang attribute. The process of uploading files is determined based
on the comparison of the value of bestandsomvang and the maximum file size.
The maximum file size is the size of request bodies that must be supported, currently defined around 4GB.
There are three options:
EnkelvoudigInformatieObject contains only metadata
without file content. The EnkelvoudigInformatieObject is created using a
single request to Documenten API.inhoud attribute, using a single request.In this tutorial we will consider all three ways to create an
EnkelvoudigInformatieObject, based on the file sizes.
The process choice depends on the maximum file size. The default value of this parameter is 4GB (or 4294967296 Bytes).
Creation of EnkelvoudigInformatieObject requires the link to
informatieobjecttype, therefore we need to set up an InformatieobjectType
first.
Open http://<ztc-ip>:8002/admin/ in your browser and log in with your
username and password. The API address is from the
‘installatie en configuratie’ tutorial.
A Catalogus represents the collection of InformatieobjectTypes and other
objects.
In the previous part we have created an InformatieobjectType. We retrieve it
now to obtain the resource url.
Get Catalogussen:
GET http://<ztc-ip>:8002/api/v1/catalogussen HTTP/1.0
Authorization: Bearer abcd1234
Example response:
[
{
"url": "<catalogus url>",
"domein": "DEMO",
"rsin": "123456782",
"contactpersoonBeheerNaam": "VNG API-lab",
"contactpersoonBeheerTelefoonnummer": "+31 (0)20 123 45 67",
"contactpersoonBeheerEmailadres": "vngapilab@example.com",
"zaaktypen": [],
"besluittypen": [],
"informatieobjecttypen": [
"<informatieobjecttype url>"
]
}
]
Now we have found a informatieobjecttype url, which we will use in the next step.
Now we will create EnkelvoudigInformatieObject, using all three different ways
to upload the file data.
EnkelvoudigInformatieObject without file.To create an EnkelvoudigInformatieObject only with metadata we need:
inhoud field emptybestandsomvang = 0
Example request:
POST http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten HTTP/1.0
Authorization: Bearer abcd1234
Content-Type: application/json
{
"identificatie": "12345",
"bronorganisatie": "123456782",
"creatiedatum": "2019-06-27",
"titel": "detailed summary",
"auteur": "document auteur",
"taal": "eng",
"bestandsomvang": 0,
"bestandsnaam": "file_name",
"informatieobjecttype": "<informatieobjecttype url>",
"vertrouwelijkheidaanduiding": "openbaar"
}
The response contains the created document without lock.
EnkelvoudigInformatieObject with small fileTo create the EnkelvoudigInformatieObject with a file size less or equal to
the maximum file size we need to:
inhoud attribute.set bestandsomvang = the actual size of file, before base64-encoding.
Example request:
POST http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten HTTP/1.0
Authorization: Bearer abcd1234
Content-Type: application/json
{
"identificatie": "12345",
"bronorganisatie": "123456782",
"creatiedatum": "2019-06-27",
"titel": "detailed summary",
"auteur": "document auteur",
"taal": "eng",
"bestandsomvang": 17,
"bestandsnaam": "file_name",
"inhoud": "c29tZSBmaWxlIGNvbnRlbnQ=",
"informatieobjecttype": "<informatieobjecttype url>",
"vertrouwelijkheidaanduiding": "openbaar"
}
The EnkelvoudigInformatieObject is created without lock.
Note that the response contains the download-url of the file in the inhoud
attribute.
EnkelvoudigInformatieObject with a large fileTo create the EnkelvoudigInformatieObject with a file size larger than the
maximum file size we need to perform several requests.
Create EnkelvoudigInformatieObject with specified file size
inhoud field emptybestandsomvang = total file size POST http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten HTTP/1.0
Authorization: Bearer abcd1234
Content-Type: application/json
{
"identificatie": "12345",
"bronorganisatie": "123456782",
"creatiedatum": "2019-06-27",
"titel": "detailed summary",
"auteur": "document auteur",
"taal": "eng",
"bestandsomvang": 5000000000,
"bestandsnaam": "file_name",
"informatieobjecttype": "<informatieobjecttype url>",
"vertrouwelijkheidaanduiding": "openbaar"
}
The created EnkelvoudigInformatieObject is locked by the API, which means
that only users with the correct lock ID can change it. The response
contains this lock ID and an array of bestandsdelen objects.
Part of example response:
{
"url": "http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten/<uuid>",
"bestandsomvang": 5000000000,
"locked": true,
"bestandsdelen": [
{
"url": "http://<drc-ip>:8000/api/v1/bestandsdelen/<uuid1>",
"volgnummer": 1,
"omvang": 4294967296,
"voltooid": false
},
{
"url": "http://<drc-ip>:8000/api/v1/bestandsdelen/<uuid2>",
"volgnummer": 2,
"omvang": 705032704,
"voltooid": false
}
],
"lock": "abcd"
}
Each of the BestandsDeel objects includes information necessary for the
upload of the file parts:
url: the URL to upload the file part tovolgnummer: the sequence number of this part. The order of merging file
parts after their upload depends on this attribute.omvang: the size of the file part in Bytesvoltooid: boolean that indicates if this file part is completely
uploaded or not.Upload file parts
Now we need to split our file into file parts so that their size matches
the sizes of the BestandsDeel objects.
After splitting the file we need to upload each file part in a separate
request. Each request must have Content-Type: multipart/form-data and
contain the following data:
lock: lock ID, which was received in the previous stepinhoud: file part content in binary formatThe example request in Postman:

In the result voltooid should change to “true”.
Unlock the EnkelvoudigInformatieObject
After uploading all the parts it is time to unlock the
EnkelvoudigInformatieObject. By unlocking, the user indicates that the
uploading process is finished and the file can be merged together from the
individual uploadeded file parts.
POST http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten/<uuid>/unlock HTTP/1.0
Authorization: Bearer abcd1234
Content-Type: application/json
{
"lock": "abcd"
}
During unlock, the following happens:
BestandsDeel resources are removedRequest the EnkelvoudigInformatieObject to verify the result
We can request the created EnkelvoudigInformatieObject to see the changes.
GET http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten/<uuid> HTTP/1.0
Authorization: Bearer abcd1234
Content-Type: application/json
Part of the example response:
{
"url": "http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten/<uuid>",
"inhoud": "http://<drc-ip>:8000/api/v1/enkelvoudiginformatieobjecten/<uuid>/download?versie=1",
"locked": false,
"bestandsdelen": []
}
Now the EnkelvoudigInformatieObject is unlocked, all bestandsdelen are
removed and the file content can be downloaded via the inhoud url.
In this tutorial, we performed some actions in the Catalogus API:
Catalogus;InformatieobjecttypeAfter that we explored 3 strategies to create a EnkelvoudigInformatieObject
in the Documenten API: