FileAPI

Top

The File API exposes basic file management functions.

DownloadFile()

Download from file resource.

Request: DownloadFileRequest
Response: streaming DownloadFileResponse

GetFile()

Get file resource metadata.

Request: GetFileRequest
Response: GetFileResponse

GetFileContent()

Get the content of a file.

Note this rpc will fail if the size of the file content is greater than 64MB, in which case use DownloadFile instead.

Request: GetFileContentRequest
Response: GetFileContentResponse

GetFileDescendants()

Get the file resource metadata of all descendants of a given file resource.

Request: GetFileDescendantsRequest
Response: GetFileDescendantsResponse

SetFileContent()

Set the content of a file.

Note this rpc will fail if the size of the file content is greater than 64MB, in which case use UploadFile instead.

Request: SetFileContentRequest
Response: SetFileContentResponse

UploadFile()

Upload data to a file resource.

Request: streaming UploadFileRequest
Response: streaming UploadFileResponse

DownloadFileRequest

FieldTypeDescription
resource_idstring

The id of the resource to download.

file_pathstring

This is required for linked folders, and represents the relative path to the source file from the base folder.

DownloadFileResponse

The response stream will contain one or more of the following messages.

Each response message will contain one of the following fields.

FieldTypeDescription
blockbytes

A chunk of file data.

statusStatus

A status will be sent when the file is completely downloaded, or if an error occurs.

GetFileContentRequest

FieldTypeDescription
resource_idstring

The resource id of the base folder.

file_pathstring

Optional - the path to the file, relative to the base folder. Required for linked folders.

GetFileContentResponse

FieldTypeDescription
statusStatus

Details of any error that occurred on the call.

contentbytes

The file content.

GetFileDescendantsRequest

FieldTypeDescription
resource_idstring

The resource id of the base folder.

file_pathstring

For linked files, this is the relative path to the 'parent' file from the base folder.

extensionstring

Optional - only match descendants of the given kind.

descendant_idstring

Optional - can be used to determine if a resource is a descendant.

GetFileDescendantsResponse

FieldTypeDescription
statusStatus

Details of any error that occurred on the call.

descendantFile repeated

The list of descendants.

GetFileRequest

FieldTypeDescription
resource_idstring

The resource id of the base folder.

file_pathstring

Optional - the path to the file, relative to the base folder. Required for linked folders.

GetFileResponse

FieldTypeDescription
statusStatus

Details of any error that occurred on the call.

fileFile

The file metadata.

SetFileContentRequest

FieldTypeDescription
resource_idstring

The resource id of the base folder.

file_pathstring

Optional - the path to the file, relative to the base folder. Required for linked folders.

store_namestring

Optional store name to use.

If specified, this will be used to extract the extension to set as a resource 'kind', e.g. tdx:ext:json.

If not specified, the extension will be taken from the name of the target resource.

contentbytes

SetFileContentResponse

FieldTypeDescription
statusStatus

Details of any error that occurred on the call.

UploadFileRequest

One of the following fields must be present.

FieldTypeDescription
startUploadFileStart

Describes the file upload, should only be sent as first message.

blockbytes

The next block of data.

UploadFileResponse

FieldTypeDescription
statusStatus

Details of any error that occurred on the call.

back_offbool

Reserved for internal use.

UploadFileStart

FieldTypeDescription
resource_idstring

The resource to upload to, required.

store_namestring

Optional store name to use.

If specified, this will be used to extract the extension to set as a resource 'kind', e.g. tdx:ext:json.

If not specified, the extension will be taken from the name of the target resource.

streaming_modebool

Optionally set streaming mode.

When in streaming mode, data is written directly to the resource.

Otherwise, data is written to a temporary file and then copied over once the upload completes successfully.

truncatebool

Optional, truncates the file prior to beginning the upload. This is only really relevant if 'streaming_mode' is set.

eager_flushbool

Optional, buffer will flush after each write.

Status

FieldTypeDescription
codeint32

A simple error code that can be easily handled by the client.

Mirrors the grpc StatusCode enum, 0 => OK

messagestring

A developer-facing human-readable error message in English. It should both explain the error and offer an actionable resolution to it.

descriptionstring

Long form error description.

File

FieldTypeDescription
file_pathstring

absolute_pathstring

file_namestring

extensionstring

sizeuint64

media_typestring

is_directorybool

modifieduint64

resource_idstring

owner_resource_idstring

Scalar Value Types

.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)