File API
Working with Files in Vendia Unis allows for the sharing of large, unstructured data objects across all participants in a Uni. Vendia’s Files are versioned and each action on a File is captured in the Uni’s ledger. This means that any actions taken on a File are recorded, providing a lineage for the File. Files are consistent across all the participants in the Uni and can be shared using Read or Write permissions. The participant (node) adding the File can determine which other nodes are allowed to read and/or write the File.
To learn more about how to upload/download Files into and out of your Uni see Getting Started with Files.
Properties
Every Vendia File has the following properties:
- _id: The unique identifier that identifies the specific file. This value is consistent across all Nodes in the Uni.
- sourceBucket: The AWS bucket from which the data was sourced for this version of the File. [only for AWS sources]
- sourceRegion: The AWS region from which the data was sourced for this version of the File. [only for AWS sources]
- sourceKey: The AWS key from which the data was sourced for this version of the File. [only for AWS sources]
- sourceVersion: The version of the AWS key from which data was sourced for this version of the File. [only for AWS sources]
- sourceUri: The unique identifier of the resource from which data was sourced for this version of the File. For Azure, this is a URL which can optionally contain either a
versionid
or asnapshot
. [only for Azure sources] - destinationKey: The unique name of the file in the Uni. The name is restricted to alphanumeric characters, periods, underscores, hyphens and spaces. Names cannot start with spaces. Names can include forward slashes to indicate the folder, however, the folder must exist already and names cannot end with a forward slash or spaces.
- copyStrategy: The copy strategy used when managing this file in the Uni. The default strategy is
ALWAYS
.- The three copy strategy options are:
ALWAYS
: Every Node in the Uni has its own copy of the File.NEVER
: Only the owning Node (the Node which added the file initially) has a copy. All other nodes have a “symbolic link” to the file.
- Note: Only the Node that adds the File with a
NEVER
copyStrategy can have write permissions to the File. - Note: The
NEVER
copyStrategy is only available for non Free Tier Unis.
- The three copy strategy options are:
- read: List of comma-separated strings that identifies the Nodes that can read the file.
- write: List of comma-separated strings that identifies the Nodes that can write to the file.
- vendia.checksums.algorithm: The hashing algorithm for which a verifiable checksum of the File was computed.
- vendia.checksums.value: The verifiable checksum of the File. The value computed for each algorithm is consistent across all Nodes in the Uni.
- etag: The node-specific value for
etag
within the node’s cloud-specific resource. - fileVersion: The node-specific value for the value within the node’s cloud-specific resource.
- createdAt: The time the file was added to the Node.
- updatedAt: The time the file was last updated.
- temporaryUrl: A URL that provides non-gated access to the File’s contents. The URL is only valid for one hour after generation. This property can be returned by a call to
getVendia_File
orlistVendia_FileItems
. Each call will generate a new URL valid for an hour.- Note: temporaryURL is only available for non Free Tier Unis.
Methods
All File methods use the same GraphQL syntax as the rest of the Uni’s API. The File API has the standard operations including methods to add, update, remove, list and get.
Add File
The basic GraphQL mutation to add a File to a Uni:
When adding a Vendia_File
entity:
destinationKey
is always requiredsourceBucket
,sourceRegion
, andsourceRegion
are required when the operation is performed against an AWS nodesourceUri
is required when the operation is performed against an Azure node
Other values are optional with the following default values:
- copyStrategy:
ALWAYS
- Every Node in the Uni has their own copy of the File. - read: All Nodes in the Uni are able to read this File.
- write: Only the Node that added the File has write permissions.
- sourceVersion: This parameter is only necessary is you are attempting to copy a specific version of the source object.
Update File
The basic GraphQL mutation to update a File in a Uni:
You must provide the file-id of the File you are attempting to update as the id
in the mutation, and the mutation’s input
must not change the value for the File’s destinationKey
.
You must have existing Write permission to be able to update a File.
All other parameters can be updated similar to adding a File; however, metadata-only updates are supported and do not require re-populating existing values.
For example, the following GraphQL mutation will only update the read
and write
permissions on an existing File:
Remove File
The basic GraphQL mutation to remove a File from a Uni:
Any node can always remove a File.
List Files
The basic GraphQL mutation to list Files in a Uni:
When retrieving a list of Files you can specify which File properties to return. Further, you can filter the list using standing GraphQL filter syntax on the existing properties. You will only receive those Files you have Read access for.
Get File
The basic GraphQL mutation to get a File from a Uni:
You must have Read permissions to get a File. Like listing Files, you can specify which properties you want returned.
Tracking Add, Update, and Put File Operations
addVendia_File
, updateVendia_File
, and putVendia_File
are all executed asynchronously and their status is reported via FileTask
objects. The {transaction{_id}}
field returned by these operations is the id of the file task tracking the operation. File tasks can be queried by calling listVendia_FileTaskItems
and getVendia_FileTask
What is in a Vendia FileTask?
A Vendia File Task contains the following fields:
field name | description |
---|---|
startTime | The timestamp when the file task started executing |
completionTime | The timestamp when the file task execution was completed |
status | The current status of the file task execution |
action | The action being performed by the file task |
fileId | The file id being acted upon by the file task |
error.errorType | The type of error that has occurred |
error.errorDetails | The details of the error that has occurred |
write | The new write list for the file |
read | The new read list for the file |
destinationKey | The new destination key for the file |
copyStrategy | The new copy strategy for the file |
sourceUri | The new source uri for Azure files |
sourceVersion | The new source version for AWS files |
sourceRegion | The new source region for AWS files |
sourceKey | The new source key for AWS files |
sourceBucket | The new source bucket for AWS files |
The following fields in the file task record are erasable:
- sourceUri
- sourceVersion
- sourceRegion
- sourceKey
- sourceBucket
FileTask execution details
When a file task execution completes successfully and updateVendia_FileTask
is ledgered alongside the original add, update, or put operation:
Error Message
The File APIs will return the standard GraphQL exceptions if invalid syntax is used. However, errors can be returned in specific instances:
- File already exists: Attempting to add a File with a duplicate
destinationKey
value. - File destination key mismatch: Attempting to update the
destinationKey
value for a File. - No write permissions: Attempting to update a File without Write permissions.
- Can’t update permissions: Attempting to update permissions on a File you are not the owner of.
- Can’t update copy strategy: Attempting to update copy strategy on a File you are not the owner of.
- File not found: Attempting to remove a file that doesn’t exist.
- Folder not found: Attempting to add a File to a Folder that doesn’t exist.
- No permission to write to folder: No permissions to add Files to the specified folder.
Limits
Next Steps
Integrating a Vendia chain with other Cloud, Web, and Mobile Services