WHAT YOU'LL LEARN
  • What methods are available on sdk.fileManager?
  • What parameters each method accepts?
  • What each method returns?
USAGE EXAMPLES

See Using the Webiny SDK for end-to-end usage examples.

Overview
anchor

The FileManagerSdk is accessed via sdk.fileManager on a Webiny instance. It provides methods for listing, uploading, updating, and deleting files. For large files, use createMultiPartUpload followed by completeMultiPartUpload. All methods return a Result type — see the SDK overview for initialization and error handling details.

Methods
anchor

getFile
anchor

Gets a single file from the file manager.

Signature:

Parameters:

ParameterTypeRequiredDescription
idstringYesID of the file to get
fieldsstring[]Yes

listFiles
anchor

Lists files from the file manager.

Signature:

Parameters:

ParameterTypeRequiredDescription
searchstringNoSearch query
whereFmFileListWhereInputNoFilter conditions
limitnumberNoMaximum number of items to return
afterstringNoCursor for pagination
sortFmFileListSorter[]NoSort order
fieldsstring[]Yes

createFile
anchor

Creates a new file in the file manager. If a file is provided, it will be uploaded to S3 first, then the record is created. If no file is provided, only the metadata record is created.

Signature:

Parameters:

ParameterTypeRequiredDescription
fileBuffer \| Blob \| FileNoOptional: The actual file content to upload
dataCreateFileDataYesThe file metadata
fieldsstring[]Yes
onProgress(progress: UploadProgress) => voidNoOptional: Progress callback
multiPartThresholdnumberNoOptional: Threshold in MB for multi-part upload (default: 100)
signalAbortSignalNoOptional: AbortSignal for cancellation

createFiles
anchor

Creates multiple files in the file manager. If files are provided, they will be uploaded to S3 first, then records are created. If no files are provided, only metadata records are created.

Signature:

Parameters:

ParameterTypeRequiredDescription
filesArray<object>YesArray of files with their data
multiPartThresholdnumberNoOptional: Threshold in MB for multi-part upload (default: 100)
concurrencynumberNoOptional: Number of concurrent uploads (default: 5)
strategyBatchUploadStrategyNoOptional: Batch upload strategy (default: FAIL_FAST)
signalAbortSignalNoOptional: AbortSignal for cancellation

updateFile
anchor

Updates a file in the file manager.

Signature:

Parameters:

ParameterTypeRequiredDescription
idstringYesID of the file to update
dataUpdateFileDataYesThe file data to update
fieldsstring[]Yes

deleteFile
anchor

Deletes a file from the file manager.

Signature:

Parameters:

ParameterTypeRequiredDescription
idstringYesID of the file to delete

listTags
anchor

Lists tags from the file manager.

Signature:

Parameters:

ParameterTypeRequiredDescription
whereFmTagsListWhereInputNoFilter conditions

getPresignedPostPayload
anchor

Gets a presigned POST payload for uploading a file to S3.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesFile name
typestringYesFile MIME type
sizenumberYesFile size in bytes
keystringNoOptional custom S3 key
keyPrefixstringNoOptional custom key prefix

getPresignedPostPayloads
anchor

Gets presigned POST payloads for uploading multiple files to S3.

Signature:

Parameters:

ParameterTypeRequiredDescription
filesGetPresignedPostPayloadParams[]YesArray of file metadata for which to get presigned POST payloads

createMultiPartUpload
anchor

Creates a multi-part upload for a large file.

Signature:

Parameters:

ParameterTypeRequiredDescription
dataobjectYesFile metadata
numberOfPartsnumberYesNumber of parts to split the file into

completeMultiPartUpload
anchor

Completes a multi-part upload.

Signature:

Parameters:

ParameterTypeRequiredDescription
fileKeystringYesS3 key of the uploaded file
uploadIdstringYesUpload ID from createMultiPartUpload