The media file API provides a persistent storage mechanism for binary media files and meta data. There are two components of a media file:

  • The MediaFile entity which describes the binary media. This is similar to other generic entity types in the API and follows the generic entity method pattern (Add, Get, Set, Remove, GetFeed).

  • The binary data of the media file. This the the actual file, for example a jpeg image. The binary files are interacted with using bespoke methods DownloadMediaFile and UploadMediaFile.
Object model

MediaFile

PropertyTypeDescription
DeviceObject
The Device associated with the file.
DriverObject
The Driver associated with the file.
FromDate
String
The from date.
IdString
The unique identifier for the specific Entity object in the Geotab system. See Id.
MediaTypeString
The MediaType.
MetaDataObject
File metadata in JSON format.
NameString
The name of this entity which identifies it and is used when displaying this entity.
SolutionIdString
The user-generated unique Id to associate the MediaFile data to a particular solution/integration (example to generate solutionId)
StatusString
The file processing Status.
TagsArray
The list of tags to provide context to the file.
ThumbnailsArray
The list of files which serve as the thumbnail for this file.
ToDate
String
The to date.
Version
String
The version of the entity.

Name and Solution ID are required.

Solution ID

A SolutionId must be created before the Storage API methods can be used within your solution. This encoded GUID is used to register and identify which solution some data is associated with. SolutionId is a mandatory parameter when calling MediaFile Add, optionally with Get. This allows each solutions' data to be isolated from the data used by other solutions. This allows multiple solutions to each have their own collection of MediaFile objects in the same database without the collections mixing. To generate your own SolutionId, please use following example.

SolutionId and AddInId are interchangeable. If you have an Add-In or integration which uses both AddInData and MediaFile you are encouraged to use a single SolutionId/AddInId.

MediaFileSearch

PropertyTypeDescription
DeviceSearchObject
Filter by the DeviceSearch options. Providing a device ID will search for any MediaFiles that are assigned to that Device. Providing the Groups will search for MediaFiles for that have Devices in that group. Available DeviceSearch options are:
  • Id
  • Group
DriverSearchObject
Search for MediaFile with this UserSearch Id. Available UserSearch options are:.
  • Id
FromDate
String
Search for MediaFile records at this date or after. Includes overlapping dates.
IdString
Search for an entry based on the specific Id.
SolutionIdString
Search for MediaFile records with this SolutionId.
TagSearchObject
Search for MediaFile with this TagSearch. Available TagSearch options are:.
  • Id
  • TagIds
ToDate
String
Search for MediaFile records at this date or before. Includes overlapping dates.

Tag

PropertyTypeDescription
IdstringGUID backed unique identifier
VersionstringEntity version. Read-only
Name*stringFile name. Must have extension. Max 1024 characters. All lower case. Required. Unique
Supported file types
TypeExtensionContent-Type
Videomp4video/mp4
Imagejpegimage/jpeg
Imagepngimage/png
Imagegifimage/gif
Imagewebpimage/webp
Security

Credentials

Credentials are required for all MediaFile and Tag related requests.

Security clearances

There are two security clearances applying to media files. By default only administrator clearance will be able to modify files, while clearances derived from view only will be able to view files. SecurityIdentifier: ViewMedia, ManageMedia.

Scope

Scope is evaluated by the scope of the requesting user to the linked entity(s) (Device and/or Driver) of the media file. A media file with no linked entity will be visible to any user in the database regardless of scope (requiring ViewMedia clearance).

API
MethodNotes
Add[MediaFile]File is added via separate API. Status = NoFile
Set[MediaFile]Updates MediaFile entity, not file
Remove[MediaFile]Removes file and MediaFile entity
Get[MediaFile]Gets only MediaFile entity
GetFeed[MediaFile]Gets a feed of only media file entity
DownloadMediaFileContent type determined by file extension. Range headers supported
UploadMediaFileMedia file entity must already be added. Content-Type “multipart/form-data”. Not “application/json”

Add

Adding a media file requires two steps:

First, adding the MediaFile entity using the generic Add method. The result of adding is the unique identifier (Id) of the added MediaFile. When the media file has been added but there is no binary uploaded the MediaFile.Status will be NoFile.

Second, uploading the MediaFile binary using the UploadMediaFile API specifying the MediaFile it relates to by Id in the JSON-RPC request. After a file is uploaded the MediaFile.Status will transition to Processing then Ready.

Processing state is available but currently unused.

Get

Like Add, Get requires two steps:

First, search for MediaFile using MediaFileSearch to provide search arguments.

Second, download the binary using the DownloadMediaFile method providing the Id of the media file.

Limits

Result limit

A maximum of 10,000 MediaFile objects will be returned from Get:MediaFile and/or GetFeed:MediaFile requests.

Rate Limit

MethodDescriptionLimitPeriodStatus
GetLimit of 350 Get requests per 1m.3501mActive
SetLimit of 60 Set requests per 1m.601mActive
AddLimit of 60 Add requests per 1m.601mActive
RemoveLimit of 60 Remove requests per 1m.601mActive
GetCountOfLimit of 100 GetCountOf requests per 1m.1001mActive
GetFeedLimit of 60 GetFeed requests per 1m.601mActive

Size limit

Image files (.png, .jpg, .gif, .webp) are limited to 10MB. Video files (.mp4) are limited to 50MB.

In MyGeotab v6.0 file size limits were increased. Images from 2MB to 10MB and of videos from 10MB to 50MB.