Files [v3]
Contents
Create File BLOB
The endpoint creates a new BLOB which is then can be used for uploading file content directly to document storage server, see Files [v2] | Create-File-by-uploading-content-directly-to-document-storage-server for more details.
Endpoint:
URL |
|
Method |
|
Content-Type |
|
Expected response code |
|
Expected response type |
|
The endpoint accepts the following query parameters:
Parameter | Type | Description | Mandatory |
|---|---|---|---|
|
| Length of the blob which is to be uploaded in bytes. | Yes |
|
| MIME type of the content which is to be uploaded. | No |
Example:
filepathname=sample.pdf
content_length=$(stat -f%z "$filepathname")
content_type=application/pdf
curl -v \
-X POST -G \
-H "Authorization: apikey $API_KEY" \
--data-urlencode "content_type=$content_type" \
--data-urlencode "content_length=$content_length" \
$COREDATA_BASE_URL/api/v3/blob/presigned-upload-url/
The response contains a JSON like this:
{
"blobName": "5a0749a8be6e454a8f2934e8717766a4",
"presignedUrl": "https://home.coredata.is/laika/5a0749a8be6e454a8f2934e8717766a4?AWSAccessKeyId=s3f%3Amyuser&Expires=1698925797&Signature=QhRPtw5mrqA0EqsP6%2FNMlU1DARc%3D"
}
Where:
blobName– is the name of the newly createdBLOBinstance.presignedUrl– is a temporary URL for uploading file content directly into theBLOB.
Create File
Create a File in a Project, Folder or Filespace.
Create File by uploading content to CoreData
Endpoint:
URL |
|
Method |
|
Content-Type |
|
Expected response code |
|
The endpoint accepts the following parameters:
Parameter | Type | Description | Mandatory |
|---|---|---|---|
|
| The name of the file to be uploaded. Example: | Yes |
|
| The title of the File. Filename without ending. Example: | No |
|
| The binary content of the file. Example: | Yes |
|
| ID of the parent, e.g. of a | Yes* |
|
| ID of the of | Yes* |
|
| ID of the of | Yes* |
|
| Name of the | No |
|
| ID of the file template. | No |
* From the list of parent fields (parent_id, project_id, space_id) we can only pass one, otherwise we will get an “400 bad request” error.
Response Location header contains URL of newly created File. The ID of the File can be derived from the Location, for example in a File URL [...]/api/v3/files/389a5280-8efc-11e6-a6e0-2f4ee7e36368/, the 389a5280-8efc-11e6-a6e0-2f4ee7e36368 is the ID of the created File.
Selecting a dynatype is optional, if no parameter is provided, then CoreData will use the dynatype File by default. Some predefined dynatype for files are:
FileContractLetterInLetterOutMemoOtherReport
Example:
filename=sample.pdf
filepathname=~/sample.pdf
title="Sample document"
parent=313ae0be-71cf-11ee-b1e9-ebd554949e29
curl -v \
-X POST \
-H "Authorization: apikey $API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "content=@$filepathname" \
-F "filename=$filename" \
-F "title=$title" \
-F "parent_id=$parent_id" \
$COREDATA_BASE_URL/api/v3/files/
Where:
filepathname– path and name of a local file to upload;filename– the name of the newFileto be created in CoreData;title– the title of the newFileto be created in CoreData;parent_id– the container in of the newFile, can be ID of eitherFilespace,ProjectorFolder.
The response contains Location header which looks like this:
Location: /api/v3/files/cb2cca52-7422-11ee-91ce-dff1c719d262/
Where the value of the reader contains the newly created file’s URL path on the target CoreData instance. The new File’s ID cb2cca52-7422-11ee-91ce-dff1c719d262 can be extracted from the Location header value.
For more information see: