File API | Vendia

File API

Working with Files in Vendia projects allows for the sharing of large, unstructured data objects across all participants in a project. Vendia’s Files are versioned and each action on a File is captured in the project’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 project and can be shared using Read or Write permissions. The participant ( workspace) adding the File can determine which other workspaces are allowed to read and/or write the File.

To learn more about how to upload/download Files into and out of your project see Getting Started with Files.

Properties

Every Vendia File has the following properties:

Methods

All File methods use the same GraphQL syntax as the rest of the project’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 project:

mutation addFile {

addVendia_File(

input: {

sourceBucket: "<bucket>",

sourceKey: "<key>",

sourceRegion: "<region>",

destinationKey: "<key>",

copyStrategy: "<strategy>",

read: [... List of **workspaces** ...],

write: [... List of **workspaces** ...]

},

syncMode: ASYNC

) {

transaction {

_id

}

}

}

When adding a Vendia_File entity:

Other values are optional with the following default values:

Update File

The basic GraphQL mutation to update a File in a project:

mutation updateFile {

updateVendia_File(

id: "my-file-id"

input: {

sourceBucket: "<bucket>"

sourceKey: "<key>"

sourceRegion: "<region>"

destinationKey: "<key>"

}

syncMode: ASYNC

) {

transaction {

_id

}

}

}

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:

mutation updateFilePermissions {

updateVendia_File(

id: "my-file-id"

input: { read: ["*"], write: ["my-workspace"] }

syncMode: ASYNC

) {

transaction {

_id

}

}

}

Remove File

The basic GraphQL mutation to remove a File from a project:

mutation removeFile {

removeVendia_File(id: "my-file-id", syncMode: ASYNC) {

transaction {

_id

}

}

}

Any workspace can always remove a File.

List Files

The basic GraphQL mutation to list Files in a project:

query listFiles {

listVendia_FileItems(filter: {}) {

Vendia_FileItems {

_id

sourceBucket

sourceKey

sourceRegion

sourceVersion

destinationKey

copyStrategy

read

write

etag

createdTime

updatedTime

temporaryUrl

fileVersion

}

}

}

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 project:

query getFile {

getVendia_File(id: "my-file-id") {

sourceBucket

sourceKey

sourceRegion

sourceVersion

destinationKey

copyStrategy

read

write

etag

createdTime

updatedTime

temporaryUrl

fileVersion

}

}

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:

FileTask execution details

When a file task execution completes successfully and updateVendia_FileTask is ledgered alongside the original add, update, or put operation:

mutation m {

file: addVendia_File(

id: "b417d4fc-18c3-b864-d126-69c3abf7bd16-018b01f4-7565-f4ef-616f-a7bb1b4360ae"

input: {

_owner: "WorkspaceTwo"

copyStrategy: ALWAYS

createdTime: "2023-10-05T22:28:27.506506+00:00"

destinationKey: "test-file.txt"

etag: "5e30215c238817405d9a9f689115b089"

fileVersion: "AmlssIaumDZljDAsDIwnNLHSuyM9myfC"

read: ["WorkspaceTwo"]

sourceBucket: "test-bucket"

sourceKey: "test-file.txt"

sourceRegion: "us-west-2"

sourceVersion: "AmlssIaumDZljDAsDIwnNLHSuyM9myfC"

updatedTime: "2023-10-05T22:28:27.506506+00:00"

vendia: {

checksums: [\
\
          { algorithm: md5, value: "5e30215c238817405d9a9f689115b089" }\
\
          {\
\
            algorithm: sha256\
\
            value: "d929a72f1a600f7f64eb704a280e940a9cbfed28ac05c3e3293c4d28b38e9e07"\
\
          }\
\
        ]

}

write: ["WorkspaceTwo"]

}

) {

error

}

fileTask: updateVendia_FileTask(

id: "018b01f4-7674-0dbe-bbbb-1b0278e8a7ac"

input: {

action: ADD

completionTime: "2023-10-05T22:28:31.158164+00:00"

status: SUCCESS

}

) {

error

}

}

Error Message

The File APIs will return the standard GraphQL exceptions if invalid syntax is used. However, errors can be returned in specific instances:

Limits

See Platform Limits and Quotas for information on the limits and quotas for Files in a project.