Getting Access to a File
In order to get access to a file, either its JSON representation or its actual content, you need:- to authenticate with a valid access token (see Authentication);
- to have either
files.readonlyorfiles.readwritescope granted to your access token; - to have a complementary token, that can only be given in the context of the API object that is related to this file and that must be passed in query parameters in order to
GET /files/{id}.
portrait, which is a reference to a file. In order to retrieve said file, you need to get the portrait link from the employee resource (which will only be returned by the server if you send ?include=links).
This link contains a token query parameter that is required to access the file.
Viewing a File: JSON vs Raw Content
When retrieving a file viaGET /files/{id}, you can either get its JSON representation (metadata) or its raw content (binary stream).
By default, the API will return the file metadata in JSON format. To get the raw content of the file, you need to set the Accept header to application/octet-stream or another appropriate MIME type (typically the one returned by the JSON metada in response.contentType).
When the Accept header is cannot be set, you can also use the disposition query parameter to specify how the file should be handled by the client. When set to inline or attachment, the API will return the raw content of the file accordingly.
Uploading a File
To upload a file to Lucca, you can use thePOST /lucca-api/files endpoint. You need to send a multipart/form-data request containing the file to be uploaded.
Make sure to authenticate with a valid access token that has the files.readwrite scope, as well as set up the multipart boundary and content correctly.