Files
The File and Folder resources allow you to operate on files and folders. While the two resources are similar, they are not exactly the same, so pay close attention to the documentation to ensure that you are operating on the correct resource for the operation you are trying to perform.
Download File
SDK Method
file.DownloadToFile()
Return Values
Returns a files_sdk.File value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
Function Arguments
| Argument | Description |
|---|---|
| params FileDownloadParams Required | Download request parameters. |
| filePath string Required | Local path to download the file to. |
FileDownloadParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
Upload File
SDK Method
file.Upload()
Return Values
Returns an error, or nil on success.
Authorization Requirement
Available to all authenticated keys or sessions.
Function Arguments
| Argument | Description |
|---|---|
| options array(UploadOption) Required | Upload options. |
Upload Options
| Option | Description |
|---|---|
| UploadWithDestinationPath | The destination path to upload the file to. |
| UploadWithFile | The local path to the file to upload. |
| UploadWithReader | A reader to upload the file from. |
| UploadWithContext | The context to upload the file with. |
Find File/Folder by Path
SDK Method
file.Find()
Return Values
Returns a files_sdk.File value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileFindParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| PreviewSize string | Request a preview size. Can be small (default), large, xlarge, or pdf. |
| WithPreviews boolean | Include file preview information? |
| WithPriorityColor boolean | Include file priority color information? |
List Folders by Path
For historical reasons, and to maintain compatibility with a variety of other cloud-based MFT and EFSS services, Folders will always be listed before Files when listing a Folder. This applies regardless of the sorting parameters you provide. These will be used, after the initial sort application of Folders before Files.
SDK Method
folder.ListFor()
Return Values
Returns a *folder.Iter and an error. Range over All() to receive files_sdk.File values and errors.
Check each loop error before using its resource. Next() and Err() remain supported.
Authorization Requirement
Available to all authenticated keys or sessions.
FolderListForParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| PreviewSize string | Request a preview size. Can be small (default), large, xlarge, or pdf. |
| Search string | If specified, will search the folders/files list by name. Ignores text before last /. This is the same API used by the search bar in the web UI when running 'Search This Folder'. Search results are a best effort, not real time, and not guaranteed to perfectly match the latest folder listing. Results may be truncated if more than 1,000 possible matches exist. This field should only be used for ad-hoc (human) searching, and not as part of an automated process. |
| SearchCustomMetadataKey string | If provided, the search string in search will search for files where this custom metadata key matches the value sent in search. Set this to * to allow any metadata key to match the value sent in search. |
| SearchAll boolean | Search entire site? If true, we will search the entire site. Do not provide a path when using this parameter. The search term must contain at least 3 characters after replacing * with spaces and trimming leading and trailing whitespace. This is the same API used by the search bar in the web UI when running 'Search All Files'. Search results are a best effort, not real time, and not guaranteed to match every file. This field should only be used for ad-hoc (human) searching, and not as part of an automated process. |
| WithPreviews boolean | Include file previews? |
| WithPriorityColor boolean | Include file priority color information? |
| Type string | Type of objects to return. Can be folder or file. |
| ModifiedAtDatetime string | If provided, will only return files/folders modified after this time. Can be used only in combination with type filter. |
Additional Arguments
Create Folder
SDK Method
folder.Create()
Return Values
Returns a files_sdk.File value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FolderCreateParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| MkdirParents boolean | Create parent directories if they do not exist? |
| ProvidedMtime string | User provided modification time. |
Update File/Folder Metadata
SDK Method
file.Update()
Return Values
Returns a files_sdk.File value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileUpdateParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| CustomMetadata object | Custom metadata map. Replaces existing metadata; an empty map clears it. Requires Full or Admin permission. Uploaders with Write permission can supply custom metadata when completing an upload instead. |
| ProvidedMtime string | Modified time of file. |
| PriorityColor string | Priority/Bookmark color of file. |
Delete File/Folder
SDK Method
file.Delete()
Return Values
Returns an error, or nil on success.
Authorization Requirement
Available to all authenticated keys or sessions.
FileDeleteParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Recursive boolean | If true, will recursively delete folders. Otherwise, will error on non-empty folders. |
Create a ZIP from one or more paths and save it to a destination path
SDK Method
file.Zip()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileZipParams Fields
| Field | Description |
|---|---|
| Paths array(string) Required | Paths to include in the ZIP. |
| Destination string Required | Destination file path for the ZIP. |
| ArchiveFormat string | Archive format to create. Possible values: zip, tar, tar.gz, tgz |
| Overwrite boolean | Overwrite existing file in the destination? |
Extract a ZIP file to a destination folder
SDK Method
file.Unzip()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileUnzipParams Fields
| Field | Description |
|---|---|
| Path string Required | ZIP file path to extract. |
| Destination string Required | Destination folder path for extracted files. |
| Filename string | Optional single entry filename to extract. |
| Overwrite boolean | Overwrite existing files in the destination? |
Encrypt a file with GPG and save it to a destination path
SDK Method
file.GpgEncrypt()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileGpgEncryptParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Destination string Required | Destination file path for the encrypted file. |
| GpgKeyIds array(int64) | GPG Key IDs to encrypt with. |
| GpgKeyPartnerId int64 | Partner ID whose GPG keys should be used for encryption. |
| SigningKeyId int64 | Optional GPG Key ID to sign with. |
| Armor boolean | Output ASCII-armored encrypted data. |
| Overwrite boolean | Overwrite existing file in the destination? |
Decrypt a GPG-encrypted file and save it to a destination path
SDK Method
file.GpgDecrypt()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileGpgDecryptParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Destination string Required | Destination file path for the decrypted file. |
| GpgKeyIds array(int64) | GPG Key IDs to decrypt with. If omitted, every accessible private GPG key in the source workspace is used. |
| GpgKeyPartnerId int64 | Partner ID whose GPG keys should be used for decryption. |
| UseAllPrivateKeys boolean | Use every accessible private GPG key in the source workspace for decryption. |
| IgnoreMdcError boolean | Ignore errors from the MDC (modification detection code) check. |
| Overwrite boolean | Overwrite existing file in the destination? |
Transform a file and save the output to a destination path
SDK Method
file.Transform()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileTransformParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Destination string Required | Destination file path for the transformed output. |
| TransformType string Required | Transform type. Supported values are image_convert, document_convert, and files_transform_script_execute. |
| TargetFormat string Required | Destination format to create. |
| Script string | Files TransformScript source. Required when transform_type is files_transform_script_execute. |
| Width int64 | Maximum output width for image_convert. |
| Height int64 | Maximum output height for image_convert. |
| Overwrite boolean | Overwrite existing file in the destination? |
Move File/Folder
SDK Method
file.Move()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileMoveParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Destination string Required | Move destination path. |
| Overwrite boolean | Overwrite existing file(s) in the destination? |
Copy File/Folder
SDK Method
file.Copy()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileCopyParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Destination string Required | Copy destination path. |
| CopyBehaviors boolean | If copying a folder, also copy supported behaviors, email notification subscriptions, and per-folder branding to the destination folder tree? |
| Structure boolean | Copy structure only? |
| Overwrite boolean | Overwrite existing file(s) in the destination? |
Delete File/Folder and return its File Action. A pending or processing deletion continues in the background after this returns; check its File Migration for completion. Waiting for the File Migration does not cancel the deletion
SDK Method
file.BeginDelete()
Return Values
Returns a files_sdk.FileAction value and an error.
Authorization Requirement
Available to all authenticated keys or sessions.
FileBeginDeleteParams Fields
| Field | Description |
|---|---|
| Path string Required | Path to operate on. |
| Recursive boolean | If true, will recursively delete folders. Otherwise, will error on non-empty folders. |
Upload to External Destinations
These SDK helpers upload files into external destinations without requiring callers to assemble destination-specific paths manually.
| Destination | SDK Method | ID Parameter |
|---|---|---|
| Remote Server | UploadToRemoteServer | remoteServerID |
| Snapshot | UploadToSnapshot | snapshotID |
| Child Site | UploadToChildSite | siteID |
Copy to External Destinations
These SDK helpers copy files or folders into external destinations without requiring callers to assemble destination-specific paths manually.
| Destination | SDK Method | ID Parameter |
|---|---|---|
| Remote Server | CopyToRemoteServer | remoteServerID |
| Snapshot | CopyToSnapshot | snapshotID |
| Child Site | CopyToChildSite | siteID |
Move to External Destinations
These SDK helpers move files or folders into external destinations without requiring callers to assemble destination-specific paths manually.
| Destination | SDK Method | ID Parameter |
|---|---|---|
| Remote Server | MoveToRemoteServer | remoteServerID |
| Snapshot | MoveToSnapshot | snapshotID |
| Child Site | MoveToChildSite | siteID |
The File Object
Some of the methods above return a File object. The attributes of this object are listed below.
| Attribute | Description |
|---|---|
| Path string | File/Folder path. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters. |
| CreatedById int64 | User ID of the User who created the file/folder |
| CreatedByApiKeyId int64 | ID of the API key that created the file/folder |
| CreatedByAs2IncomingMessageId int64 | ID of the AS2 Incoming Message that created the file/folder |
| CreatedByAutomationId int64 | ID of the Automation that created the file/folder |
| CreatedByBundleRegistrationId int64 | ID of the Bundle Registration that created the file/folder |
| CreatedByInboxId int64 | ID of the Inbox that created the file/folder |
| CreatedByRemoteServerId int64 | ID of the Remote Server that created the file/folder |
| CreatedBySyncId int64 | ID of the Sync that created the file/folder |
| CustomMetadata object | Custom metadata map of keys and values. Limited to 32 keys, 256 characters per key and 1024 characters per value. |
| DisplayName string | File/Folder display name |
| Type string | Type: directory or file. |
| Size int64 | File/Folder size |
| CreatedAt date-time | File created date/time |
| LastModifiedById int64 | User ID of the User who last modified the file/folder |
| LastModifiedByApiKeyId int64 | ID of the API key that last modified the file/folder |
| LastModifiedByAutomationId int64 | ID of the Automation that last modified the file/folder |
| LastModifiedByBundleRegistrationId int64 | ID of the Bundle Registration that last modified the file/folder |
| LastModifiedByRemoteServerId int64 | ID of the Remote Server that last modified the file/folder |
| LastModifiedBySyncId int64 | ID of the Sync that last modified the file/folder |
| Mtime date-time | File last modified date/time, according to the server. This is the timestamp of the last Files.com operation of the file, regardless of what modified timestamp was sent. |
| ProvidedMtime date-time | File last modified date/time, according to the client who set it. Files.com allows desktop, FTP, SFTP, and WebDAV clients to set modified at times. This allows Desktop<->Cloud syncing to preserve modified at times. |
| Crc32 string | File CRC32 checksum. This is sometimes delayed, so if you get a blank response, wait and try again. |
| Md5 string | File MD5 checksum. This is sometimes delayed, so if you get a blank response, wait and try again. |
| Sha1 string | File SHA1 checksum. This is sometimes delayed, so if you get a blank response, wait and try again. |
| Sha256 string | File SHA256 checksum. This is sometimes delayed, so if you get a blank response, wait and try again. |
| MimeType string | MIME Type. This is determined by the filename extension and is not stored separately internally. |
| Region string | Region location |
| Permissions string | A short string representing the current user's permissions. Can be r (Read),w (Write),d (Delete), l (List) or any combination |
| SubfoldersLocked boolean | Are subfolders locked and unable to be modified? |
| IsLocked boolean | Is this folder locked and unable to be modified? |
| DownloadUri string | Link to download file. Provided only in response to a download request. |
| DirectConnectionInfo DirectConnectionInfo | Optional direct connection information for direct Agent transfer attempts |
| PriorityColor string | Bookmark/priority color of file/folder |
| PreviewId int64 | File preview ID |
| Preview Preview | File preview |
custom_metadata
Custom metadata map of keys and values. Limited to 32 keys, 256 characters per key and 1024 characters per value.
| Value type | Description |
|---|---|
| object of string values | Custom metadata map of keys and values. Limited to 32 keys, 256 characters per key and 1024 characters per value. At most 32 keys. |