Skip to main content

Files

File management collection for uploading, storing, and manipulating files within the TrackVision system.

The file Object

File collection stores metadata and access information for all uploaded files within the system.

Field NameTypeDescription
iduuidPrimary key of the file.
storagestringStorage adapter used for the file.
filename_diskstringName of the file as saved on the storage adapter.
filename_downloadstringPreferred filename when file is downloaded.
titlestringTitle for the file.
typestringMimetype of the file.
folderobjectVirtual folder the file is in. Links to Folders.
created_ondatetimeTimestamp when the file was created.
uploaded_byobjectUser who uploaded the file. Links to Users.
uploaded_ondatetimeTimestamp when the file was last uploaded/replaced.
modified_byobjectUser who last updated the file. Links to Users.
filesizeintegerSize of the file in bytes.
widthintegerWidth in pixels if the file is an image/video. Auto-extracted for images.
heightintegerHeight in pixels if the file is an image/video. Auto-extracted for images.
focal_point_xintegerX coordinate for image cropping center point.
focal_point_yintegerY coordinate for image cropping center point.
durationintegerDuration in milliseconds if the file contains audio/video. Not auto-extracted.
descriptionstringDescription of the file.
locationstringLocation information for the file.
tagsarray of objectsTags associated with the file.
metadataobjectAdditional metadata scraped from the file (Exif, IPTC, ICC for images).

List Files

List all files that exist in TrackVision.

Request

GET /files

Query Parameters

Supports all global query parameters.

Response

An array of up to limit file objects. If no items are available, data will be an empty array.

Example

GET /files

Retrieve a File

Retrieve a single file by primary key.

Request

GET /files/:id

Query Parameters

Supports all global query parameters.

Response

Returns a file object if a valid primary key was provided.

Example

GET /files/0fca80c4-d61c-4404-9fd7-6ba86b64154d

Upload a File

Upload a new file.

Request

POST /files

Body must be formatted as a multipart/form-data with a final property called file.

The file contents has to be provided in a property called file. All other properties of the file object can be provided as well, except filename_disk and filename_download.

Order Matters

Make sure to define the non-file properties for each file first. This ensures that the file metadata is associated with the correct file.

Query Parameters

Supports all global query parameters.

Response

Returns the file object for the uploaded file, or an array of file objects if multiple files were uploaded at once.

Example

POST /files


Content-Type: multipart/form-data; boundary=boundary

--boundary
Content-Disposition: form-data; name="title"

example
--boundary
Content-Disposition: form-data; name="file"; filename="example.txt"

< ./example.txt

--boundary

Import a File

Import a file from the web

Request

POST /files/import

{
"url": file_url,
"data": file_object
}

Query Parameters

Supports all global query parameters.

Request Body

url Required
The URL to download the file from.

data
Any of the file object's properties.

Response

Returns the file object for the imported file.

Example

POST /files/import

{
"url": "https://source.unsplash.com/random",
"data": {
"title": "Example"
}
}

Update a File

Update an existing file, and/or replace it's file contents.

Request

PATCH /files/:id

Provide a partial file object as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

You can either submit a JSON object consisting of a partial file object to update the file meta, or send a multipart/form-data request to replace the file contents on disk. See Upload a File for more information on the structure of this multipart/form-data request.

Response

Returns the file object for the updated file.

Example

PATCH /files/0fca80c4-d61c-4404-9fd7-6ba86b64154d

{
"title": "Example"
}

Update Multiple Files

Update multiple files at the same time.

Request

PATCH /files

{
"keys": file_id_array ,
"data": partial_file_object
}

Query Parameters

Supports all global query parameters.

Request Body

keys Required
Array of primary keys of the files you'd like to update.

data Required
Any of the file object's properties.

Response

Returns the file objects for the updated files.

Example

PATCH /files

{
"keys": ["b6123925-2fc0-4a30-9d86-863eafc0a6e7", "d17c10aa-0bad-4864-9296-84f522c753e5"],
"data": {
"tags": ["cities"]
}
}

Delete a File

Delete an existing file.

Destructive

This will also delete the file from disk.

Request

DELETE /files/:id

Query Parameters

Supports all global query parameters.

Response

Empty response.

Example

DELETE /files/0fca80c4-d61c-4404-9fd7-6ba86b64154d

Delete Multiple Files

Delete multiple files at once.

Destructive

This will also delete the files from disk.

Request

DELETE /files

Provide an array of file IDs as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

Array of file primary keys

Returns

Empty response.

Example

DELETE /files

["d17c10aa-0bad-4864-9296-84f522c753e5", "b6123925-2fc0-4a30-9d86-863eafc0a6e7"]