Small file: < 3GB Large file: > 3GB
Summary, each case is specified in more detail further in this document.
- creating a new document:
- small file -> inline, base64 encoded upload, together with metadata (= current situation)
- large file: use multiple upload URLs, based on
bestandsomvang
- updating an existing document
- updating only the metadata
- updating the content itself with a small file -> inline
- updating the content itself with a large file -> upload URLs
POST /api/v1/enkelvoudiginformatieobjecten
inhoud
is base64 encoded- the entire POST body must be < 4GB, or nginx/uwsgi throws an error (HTTP 413)
- [validation] the file size should match the provided
bestandsgrootte
field - No
BestandsDeel
objects should be created - The document is not locked, the entire creation takes place in a single API call and database transaction
This decision is made if inhoud
is empty, otherwise you are in the
previous situation.
POST /api/v1/enkelvoudiginformatieobjecten
with only metadata (andbestandsgrootte
field)BestandsDeel
objects are prepared- the document is immediately assigned a lock ID to prevent others from messing with the content/upload
- the response contains the upload URLs and lock ID
- Client
PUT /api/v1/bestandsdelen
- Upload
inhoud
- [validation]
inhoud.size
must matchgrootte
- [validation] lock ID must be provided and match the lock set on the document itself
- Upload
- If you
retrieve
the document, the response contains:inhoud: null
-> because the file uploads are not ready yetlocked: true
- Finalizing the upload is done by unlocking the document
- [validation] Validate that the lock ID is correct
- [validation] Validate that all part uploads are completed, if not, communicate which part(s) (url and index) is (are) incomplete
- Stitch the files together and assign to the document
- Remove the lock of the document
- Notifications: probably the
create
action notification should only be set after the upload has completed, NOT when a locked document is initially created.
PATCH
is straight forward, the existing machinery remains:
- Lock document
PATCH
only relevant metadata fields- [validation]
inhoud
may NOT be present
- [validation]
- Create new version and set same file as previous version
- Unlock document
With PUT, the entire resource is replaced. The inhoud
field can be left
empty/absent.
- Lock document
PUT
resource, withoutinhoud
- Create
BestandsDeel
forbestandsgrootte
that's provided - response with the upload URLs in the body
- Create
- Client ignores the upload URLs - the parts remain empty
- Create new version and set same file as previous version if all upload parts are empty
- Unlock document
- Discard the upload parts
Inline updates are allowed for small files
- Lock document
PUT
orPATCH
to/api/v1/enkelvoudiginformatieobjecten/<uuid>
inhoud
is base64 encoded- the entire
PUT
/PATCH
body must be < 4GB, or nginx/uwsgi throws an error (HTTP 413) - [validation] the file size should match the provided
bestandsgrootte
field (or be derived from it?) - No
BestandsDeel
objects should be created - Unlock document
Without inline file updates
- Lock document
PUT
orPATCH
to/api/v1/enkelvoudiginformatieobjecten/<uuid>
- include the
bestandsgrootte: 100000
value to prepareBestandsDelen
- response contains upload URLs
- include the
- Client
PUT /api/v1/bestandsdelen
- Upload
inhoud
- [validation]
inhoud.size
must matchgrootte
- [validation] lock ID must be provided and match the lock set on the document itself
- Upload
- If you
retrieve
the document, the response contains:inhoud: null
-> because the file uploads are not ready yetlocked: true
- Finalizing the upload is done by unlocking the document
- [validation] Validate that the lock ID is correct
- [validation] Validate that all part uploads are completed, if not, communicate which part(s) (url and index) is (are) incomplete
- Stitch the files together and assign to the document
- Remove the lock of the document
- Notifications: probably the
(partial)_update
action notification should only be set after the upload has completed, NOT when a locked document is initially updated w/ the metadata/preparation.
The serializer for Documents must:
-
change behaviour on create based on
inhoud
being present or not. This means that theinhoud
field is declared as optionally. -
metadata-only is detected as
inhoud
being empty/absent OR all upload parts being empty when the document is being unlocked.
Complete
action
Removing this and merging it with the unlock
action.
- Application locks document
- Upload is prepared (=
BestandsDeel
objects are created - What happens if an administrator forcibly unlocks the document?
Proposal: discard BestandsDeel
objects, assign previous version of inhoud
and unlock document.