Categorygithub.com/Files-com/files-sdk-go

# README

Files.com Go Client

The content included here should be enough to get started, but please visit our Developer Documentation Website for the complete documentation.

Introduction

The Files.com Go client library provides convenient access to all aspects of Files.com from applications written in the Go language.

Files.com customers use our Go client library for directly working with files and folders as well as performing management tasks such as adding/removing users, onboarding counterparties, retrieving information about automations and more.

Installation

Make sure your project is using Go Modules (it will have a go.mod file in its root if it already is):

go mod init

Then, reference files-sdk-go in a Go program with import:

import (
    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/folder"
)

Run any of the normal go commands (build/install/test). The Go toolchain will resolve and fetch the files module automatically.

Files.com is Committed to Go

Go is a core language used by the Files.com team for internal development. This library is directly used by the Files.com CLI app, Files.com Desktop App v6, the official Files.com Terraform integration, and the official Files.com RClone integration.

As such, this library is actively developed and should be expected to be highly performant.

Explore the files-sdk-go code on GitHub.

Getting Support

The Files.com Support team provides official support for all of our official Files.com integration tools.

To initiate a support conversation, you can send an Authenticated Support Request or simply send an E-Mail to [email protected].

Authentication

There are two ways to authenticate: API Key authentication and Session-based authentication.

Authenticate with an API Key

Authenticating with an API key is the recommended authentication method for most scenarios, and is the method used in the examples on this site.

To use an API Key, first generate an API key from the web interface or via the API or an SDK.

Note that when using a user-specific API key, if the user is an administrator, you will have full access to the entire API. If the user is not an administrator, you will only be able to access files that user can access, and no access will be granted to site administration functions in the API.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/folder"
)

// You can specify an API key in the GlobalConfig, and use that config when creating clients.
files_sdk.GlobalConfig.APIKey = "YOUR_API_KEY"
client := folder.Client{Config: files_sdk.GlobalConfig}
it, err := client.ListFor(files_sdk.FolderListForParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

// Alternatively, you can specify the API key on a per-request basis using the Config struct.
config := files_sdk.Config{APIKey: "YOUR_API_KEY"}.Init()
client := folder.Client{Config: config}
it, err := client.ListFor(files_sdk.FolderListForParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

// If the API Key is available in the `FILES_API_KEY` environment variable you do not need to create clients.
it, err := folder.ListFor(files_sdk.FolderListForParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Don't forget to replace the placeholder, YOUR_API_KEY, with your actual API key.

Authenticate with a Session

You can also authenticate by creating a user session using the username and password of an active user. If the user is an administrator, the session will have full access to all capabilities of Files.com. Sessions created from regular user accounts will only be able to access files that user can access, and no access will be granted to site administration functions.

Sessions use the exact same session timeout settings as web interface sessions. When a session times out, simply create a new session and resume where you left off. This process is not automatically handled by our SDKs because we do not want to store password information in memory without your explicit consent.

Logging In

To create a session, create a session Client object that points to the subdomain of the Files.com site.

The Create method on the session client can then be used to create a Session object which can be used to authenticate SDK method calls.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/folder"
    "github.com/Files-com/files-sdk-go/v3/session"
)

sessionClient := session.Client{}
thisSession, err := sessionClient.Create(files_sdk.SessionCreateParams{Username: "USERNAME", Password: "PASSWORD"})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

config := files_sdk.Config{SessionId: thisSession.Id}.Init()
folderClient := folder.Client{Config: config}

it, err := folderClient.ListFor(files_sdk.FolderListForParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Using a Session

Once a session has been created, the Session.Id can be set in a Config object, which can then be used to authenticate Client objects.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/folder"
)

config := files_sdk.Config{SessionId: thisSession.Id}.Init()
folderClient := folder.Client{Config: config}

it, err := folderClient.ListFor(files_sdk.FolderListForParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Logging Out

User sessions can be ended by calling Delete() on the Session client.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/session"
)

sessionClient := session.Client{Config: files_sdk.Config{SessionId: thisSession.Id}.Init()}
err := sessionClient.Delete()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Configuration

Global configuration is performed by providing a files_sdk.Config object to the Client.

Configuration Options

Base URL

Setting the base URL for the API is required if your site is configured to disable global acceleration. This can also be set to use a mock server in development or CI.

import (
    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/file"
)

config := files_sdk.Config{
    EndpointOverride: "https://MY-SUBDOMAIN.files.com",
}.Init()
client := file.Client{Config: config}

Sort and Filter

Several of the Files.com API resources have list operations that return multiple instances of the resource. The List operations can be sorted and filtered.

Sorting

To sort the returned data, pass in the SortBy method argument.

Each resource supports a unique set of valid sort fields and can only be sorted by one field at a time.

The argument value is a Go map[string]interface{} map that has a key of the resource field name to sort on and a value of either "asc" or "desc" to specify the sort order.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/user"
)

client := user.Client{Config: files_sdk.GlobalConfig}

// users sorted by username
parameters := files_sdk.UserListParams{SortBy: map[string]interface{}{"username":"asc"}}
userIterator, err := client.List(parameters)
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for userIterator.Next() {
  user := userIterator.User()
  fmt.Println(user.Username)
}
err = userIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Filtering

Filters apply selection criteria to the underlying query that returns the results. They can be applied individually or combined with other filters, and the resulting data can be sorted by a single field.

Each resource supports a unique set of valid filter fields, filter combinations, and combinations of filters and sort fields.

For the filter type of Filter, the passed in argument value is an initialized resource struct. Struct fields are initialized with values to use in the filter.

For the other filter types, the passed in argument is a Go map[string]interface{} map that has a key of the resource field name to filter on and a passed in value to use in the filter comparison.

Filter Types

FilterTypeDescription
FilterExactFind resources that have an exact field value match to a passed in value. (i.e., FIELD_VALUE = PASS_IN_VALUE).
FilterPrefixPatternFind resources where the specified field is prefixed by the supplied value. This is applicable to values that are strings.
FilterGtRangeFind resources that have a field value that is greater than the passed in value. (i.e., FIELD_VALUE > PASS_IN_VALUE).
FilterGteqRangeFind resources that have a field value that is greater than or equal to the passed in value. (i.e., FIELD_VALUE >= PASS_IN_VALUE).
FilterLtRangeFind resources that have a field value that is less than the passed in value. (i.e., FIELD_VALUE < PASS_IN_VALUE).
FilterLteqRangeFind resources that have a field value that is less than or equal to the passed in value. (i.e., FIELD_VALUE <= PASS_IN_VALUE).
import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/user"
)

client := user.Client{Config: files_sdk.GlobalConfig}

// non admin users
filter_value := true;
parameters := files_sdk.UserListParams{
    Filter: files_sdk.User{NotSiteAdmin: &filter_value}
}
userIterator, err := client.List(parameters)
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for userIterator.Next() {
  user := userIterator.User()
  fmt.Println(user.Username)
}
err = userIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}
import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/user"
)

client := user.Client{Config: files_sdk.GlobalConfig};

// users who haven't logged in since 2024-01-01
parameters := files_sdk.UserListParams{
    FilterLt: map[string]interface{}{"last_login_at": "2024-01-01"}
}
userIterator, err := client.List(parameters)
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for userIterator.Next() {
  user := userIterator.User()
  fmt.Println(user.Username)
}
err = userIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}
import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/user"
)

client := user.Client{Config: files_sdk.GlobalConfig};

// users whose usernames start with 'test'
parameters := files_sdk.UserListParams{
    FilterPrefix: map[string]interface{}{"username": "test"}
}
userIterator, err := client.List(parameters)
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for userIterator.Next() {
  user := userIterator.User()
  fmt.Println(user.Username)
}
err = userIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}
import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/user"
)

client := user.Client{Config: files_sdk.GlobalConfig};

// users whose usernames start with 'test' and are not admins
filterValue := true;
parameters := files_sdk.UserListParams{
    FilterPrefix: map[string]interface{}{"username": "test"},
    Filter:       files_sdk.User{NotSiteAdmin: &filterValue},
    SortBy:       map[string]interface{}{"username": "asc"}
}
userIterator, err := client.List(parameters)
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for userIterator.Next() {
  user := userIterator.User()
  fmt.Println(user.Username)
}
err = userIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Errors

The Files.com Go SDK will return errors from function/method calls using the standard Go error handling pattern.

The returned errors fall into basic categories:

  1. error - errors that originate in the SDK or standard libraries.
  2. ResponseError - errors that occur due to the response from the Files.com API.

The error type are errors that implement the type error interface and the error specifics can be accessed with the Error() method.

ResponseError also implements the type error interface but is a custom error with additional data.

The additional data includes:

  • Type - the type of error returned by the Files.com API
  • Title - a description of the error returned by the Files.com API
  • ErrorMessage - additional error information
import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/session"
)

thisSession, err := session.Create(files_sdk.SessionCreateParams{ Username: "USERNAME", Password: "BADPASSWORD" })
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

ResponseError Types

ResponseError errors have additional data returned from the Files.com API to help determine the cause of the error.

TypeTitle
bad-requestBad Request
bad-request/agent-upgrade-requiredAgent Upgrade Required
bad-request/attachment-too-largeAttachment Too Large
bad-request/cannot-download-directoryCannot Download Directory
bad-request/cant-move-with-multiple-locationsCant Move With Multiple Locations
bad-request/datetime-parseDatetime Parse
bad-request/destination-sameDestination Same
bad-request/does-not-support-sortingDoes Not Support Sorting
bad-request/folder-must-not-be-a-fileFolder Must Not Be A File
bad-request/folders-not-allowedFolders Not Allowed
bad-request/invalid-bodyInvalid Body
bad-request/invalid-cursorInvalid Cursor
bad-request/invalid-cursor-type-for-sortInvalid Cursor Type For Sort
bad-request/invalid-etagsInvalid Etags
bad-request/invalid-filter-alias-combinationInvalid Filter Alias Combination
bad-request/invalid-filter-fieldInvalid Filter Field
bad-request/invalid-filter-paramInvalid Filter Param
bad-request/invalid-filter-param-formatInvalid Filter Param Format
bad-request/invalid-filter-param-valueInvalid Filter Param Value
bad-request/invalid-input-encodingInvalid Input Encoding
bad-request/invalid-interfaceInvalid Interface
bad-request/invalid-oauth-providerInvalid Oauth Provider
bad-request/invalid-pathInvalid Path
bad-request/invalid-return-to-urlInvalid Return To Url
bad-request/invalid-sort-fieldInvalid Sort Field
bad-request/invalid-sort-filter-combinationInvalid Sort Filter Combination
bad-request/invalid-upload-offsetInvalid Upload Offset
bad-request/invalid-upload-part-gapInvalid Upload Part Gap
bad-request/invalid-upload-part-sizeInvalid Upload Part Size
bad-request/method-not-allowedMethod Not Allowed
bad-request/multiple-sort-params-not-allowedMultiple Sort Params Not Allowed
bad-request/no-valid-input-paramsNo Valid Input Params
bad-request/part-number-too-largePart Number Too Large
bad-request/path-cannot-have-trailing-whitespacePath Cannot Have Trailing Whitespace
bad-request/reauthentication-needed-fieldsReauthentication Needed Fields
bad-request/request-params-contain-invalid-characterRequest Params Contain Invalid Character
bad-request/request-params-invalidRequest Params Invalid
bad-request/request-params-requiredRequest Params Required
bad-request/search-all-on-child-pathSearch All On Child Path
bad-request/unrecognized-sort-indexUnrecognized Sort Index
bad-request/unsupported-currencyUnsupported Currency
bad-request/unsupported-http-response-formatUnsupported Http Response Format
bad-request/unsupported-media-typeUnsupported Media Type
bad-request/user-id-invalidUser Id Invalid
bad-request/user-id-on-user-endpointUser Id On User Endpoint
bad-request/user-requiredUser Required
not-authenticated/additional-authentication-requiredAdditional Authentication Required
not-authenticated/api-key-sessions-not-supportedApi Key Sessions Not Supported
not-authenticated/authentication-requiredAuthentication Required
not-authenticated/bundle-registration-code-failedBundle Registration Code Failed
not-authenticated/files-agent-token-failedFiles Agent Token Failed
not-authenticated/inbox-registration-code-failedInbox Registration Code Failed
not-authenticated/invalid-credentialsInvalid Credentials
not-authenticated/invalid-oauthInvalid Oauth
not-authenticated/invalid-or-expired-codeInvalid Or Expired Code
not-authenticated/invalid-sessionInvalid Session
not-authenticated/invalid-username-or-passwordInvalid Username Or Password
not-authenticated/locked-outLocked Out
not-authenticated/lockout-region-mismatchLockout Region Mismatch
not-authenticated/one-time-password-incorrectOne Time Password Incorrect
not-authenticated/two-factor-authentication-errorTwo Factor Authentication Error
not-authenticated/two-factor-authentication-setup-expiredTwo Factor Authentication Setup Expired
not-authorized/api-key-is-disabledApi Key Is Disabled
not-authorized/api-key-is-path-restrictedApi Key Is Path Restricted
not-authorized/api-key-only-for-desktop-appApi Key Only For Desktop App
not-authorized/api-key-only-for-mobile-appApi Key Only For Mobile App
not-authorized/api-key-only-for-office-integrationApi Key Only For Office Integration
not-authorized/billing-or-site-admin-permission-requiredBilling Or Site Admin Permission Required
not-authorized/billing-permission-requiredBilling Permission Required
not-authorized/bundle-maximum-uses-reachedBundle Maximum Uses Reached
not-authorized/cannot-login-while-using-keyCannot Login While Using Key
not-authorized/cant-act-for-other-userCant Act For Other User
not-authorized/contact-admin-for-password-change-helpContact Admin For Password Change Help
not-authorized/files-agent-failed-authorizationFiles Agent Failed Authorization
not-authorized/folder-admin-or-billing-permission-requiredFolder Admin Or Billing Permission Required
not-authorized/folder-admin-permission-requiredFolder Admin Permission Required
not-authorized/full-permission-requiredFull Permission Required
not-authorized/history-permission-requiredHistory Permission Required
not-authorized/insufficient-permission-for-paramsInsufficient Permission For Params
not-authorized/insufficient-permission-for-siteInsufficient Permission For Site
not-authorized/must-authenticate-with-api-keyMust Authenticate With Api Key
not-authorized/need-admin-permission-for-inboxNeed Admin Permission For Inbox
not-authorized/non-admins-must-query-by-folder-or-pathNon Admins Must Query By Folder Or Path
not-authorized/not-allowed-to-create-bundleNot Allowed To Create Bundle
not-authorized/password-change-not-requiredPassword Change Not Required
not-authorized/password-change-requiredPassword Change Required
not-authorized/read-only-sessionRead Only Session
not-authorized/read-permission-requiredRead Permission Required
not-authorized/reauthentication-failedReauthentication Failed
not-authorized/reauthentication-failed-finalReauthentication Failed Final
not-authorized/reauthentication-needed-actionReauthentication Needed Action
not-authorized/recaptcha-failedRecaptcha Failed
not-authorized/self-managed-requiredSelf Managed Required
not-authorized/site-admin-requiredSite Admin Required
not-authorized/site-files-are-immutableSite Files Are Immutable
not-authorized/two-factor-authentication-requiredTwo Factor Authentication Required
not-authorized/user-id-without-site-adminUser Id Without Site Admin
not-authorized/write-and-bundle-permission-requiredWrite And Bundle Permission Required
not-authorized/write-permission-requiredWrite Permission Required
not-foundNot Found
not-found/api-key-not-foundApi Key Not Found
not-found/bundle-path-not-foundBundle Path Not Found
not-found/bundle-registration-not-foundBundle Registration Not Found
not-found/code-not-foundCode Not Found
not-found/file-not-foundFile Not Found
not-found/file-upload-not-foundFile Upload Not Found
not-found/folder-not-foundFolder Not Found
not-found/group-not-foundGroup Not Found
not-found/inbox-not-foundInbox Not Found
not-found/nested-not-foundNested Not Found
not-found/plan-not-foundPlan Not Found
not-found/site-not-foundSite Not Found
not-found/user-not-foundUser Not Found
processing-failureProcessing Failure
processing-failure/already-completedAlready Completed
processing-failure/automation-cannot-be-run-manuallyAutomation Cannot Be Run Manually
processing-failure/behavior-not-allowed-on-remote-serverBehavior Not Allowed On Remote Server
processing-failure/bundle-only-allows-previewsBundle Only Allows Previews
processing-failure/bundle-operation-requires-subfolderBundle Operation Requires Subfolder
processing-failure/could-not-create-parentCould Not Create Parent
processing-failure/destination-existsDestination Exists
processing-failure/destination-folder-limitedDestination Folder Limited
processing-failure/destination-parent-conflictDestination Parent Conflict
processing-failure/destination-parent-does-not-existDestination Parent Does Not Exist
processing-failure/exceeded-runtime-limitExceeded Runtime Limit
processing-failure/expired-private-keyExpired Private Key
processing-failure/expired-public-keyExpired Public Key
processing-failure/export-failureExport Failure
processing-failure/export-not-readyExport Not Ready
processing-failure/failed-to-change-passwordFailed To Change Password
processing-failure/file-lockedFile Locked
processing-failure/file-not-uploadedFile Not Uploaded
processing-failure/file-pending-processingFile Pending Processing
processing-failure/file-processing-errorFile Processing Error
processing-failure/file-too-big-to-decryptFile Too Big To Decrypt
processing-failure/file-too-big-to-encryptFile Too Big To Encrypt
processing-failure/file-uploaded-to-wrong-regionFile Uploaded To Wrong Region
processing-failure/filename-too-longFilename Too Long
processing-failure/folder-lockedFolder Locked
processing-failure/folder-not-emptyFolder Not Empty
processing-failure/history-unavailableHistory Unavailable
processing-failure/invalid-bundle-codeInvalid Bundle Code
processing-failure/invalid-file-typeInvalid File Type
processing-failure/invalid-filenameInvalid Filename
processing-failure/invalid-priority-colorInvalid Priority Color
processing-failure/invalid-rangeInvalid Range
processing-failure/invalid-siteInvalid Site
processing-failure/model-save-errorModel Save Error
processing-failure/multiple-processing-errorsMultiple Processing Errors
processing-failure/path-too-longPath Too Long
processing-failure/recipient-already-sharedRecipient Already Shared
processing-failure/remote-server-errorRemote Server Error
processing-failure/resource-belongs-to-parent-siteResource Belongs To Parent Site
processing-failure/resource-lockedResource Locked
processing-failure/subfolder-lockedSubfolder Locked
processing-failure/two-factor-authentication-code-already-sentTwo Factor Authentication Code Already Sent
processing-failure/two-factor-authentication-country-blacklistedTwo Factor Authentication Country Blacklisted
processing-failure/two-factor-authentication-general-errorTwo Factor Authentication General Error
processing-failure/two-factor-authentication-method-unsupported-errorTwo Factor Authentication Method Unsupported Error
processing-failure/two-factor-authentication-unsubscribed-recipientTwo Factor Authentication Unsubscribed Recipient
processing-failure/updates-not-allowed-for-remotesUpdates Not Allowed For Remotes
rate-limited/duplicate-share-recipientDuplicate Share Recipient
rate-limited/reauthentication-rate-limitedReauthentication Rate Limited
rate-limited/too-many-concurrent-loginsToo Many Concurrent Logins
rate-limited/too-many-concurrent-requestsToo Many Concurrent Requests
rate-limited/too-many-login-attemptsToo Many Login Attempts
rate-limited/too-many-requestsToo Many Requests
rate-limited/too-many-sharesToo Many Shares
service-unavailable/agent-unavailableAgent Unavailable
service-unavailable/automations-unavailableAutomations Unavailable
service-unavailable/migration-in-progressMigration In Progress
service-unavailable/site-disabledSite Disabled
service-unavailable/uploads-unavailableUploads Unavailable
site-configuration/account-already-existsAccount Already Exists
site-configuration/account-overdueAccount Overdue
site-configuration/no-account-for-siteNo Account For Site
site-configuration/site-was-removedSite Was Removed
site-configuration/trial-expiredTrial Expired
site-configuration/trial-lockedTrial Locked
site-configuration/user-requests-enabled-requiredUser Requests Enabled Required

{frontmatter.title}

Certain API operations return lists of objects. When the number of objects in the list is large, the API will paginate the results.

The Files.com Go SDK automatically paginates through lists of objects by default.

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    "github.com/Files-com/files-sdk-go/v3/folder"
)

fileIterator, err := folder.ListFor(files_sdk.FolderListForParams{Path: "path"})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for fileIterator.Next() {
    file := fileIterator.file()
}
err = fileIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Case Sensitivity

The Files.com API compares files and paths in a case-insensitive manner. For related documentation see Case Sensitivity Documentation.

Mock Server

Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com SDKs and other direct integrations against the Files.com API in an integration test environment.

It is a Ruby app that operates as a minimal server for the purpose of testing basic network operations and JSON encoding for your SDK or API client. It does not maintain state and it does not deeply inspect your submissions for correctness.

Eventually we will add more features intended for integration testing, such as the ability to intentionally provoke errors.

Download the server as a Docker image via Docker Hub.

The Source Code is also available on GitHub.

A README is available on the GitHub link.

# Packages

No description provided by the author