Skip to content

uploadFile

Created jdiamante 2024-03-14 Updated jgalland 2024-03-28

(Applies to server-side rulesets for core 4.2.36+)

Uploads a file to the formbird storage system with the specified properties. This function is exclusively available in server-side rulesets and is designed for operations that involve uploading files.

Syntax

ft3.uploadFile(options)

Part Description
options An object containing the file upload options
options.fileName The name of the file to be uploaded
options.fileData The data of the file being uploaded
options.fileReferenceTemplateId Template ID for the file reference
options.documentName Name of the document associated with this file
options.documentId ID of the document to which this file is being attached

Returns

A promise that resolves to an object containing the result of the upload operation, including details about the uploaded file such as its fileNo, basePath, and fileType.

Example

ft3.uploadFile({
    fileName: `sample.txt`,
    fileData: `text data`,
    fileReferenceTemplateId: `3c907500-5b1e-11ed-b7e5-1555fd6ba382`,
    documentName: `test doc name`,
    documentId: `a49055c0-18d6-11e7-b7e5-b7036f585587`
})
.then((result) => {
    // result
})
.catch(err => {  
    ntf.logger.error(err.message);
});

Sample Output

On successful execution, the output will be an object that includes details about the uploaded file. For example:

{
    "fileNo": "8b2d7588-a03d-408f-8672-4d3aca41b90e",
    "basePath": "/uploads",
    "fileType": "text/plain"
}