getFile
Created jdiamante 2024-03-14 Updated jgalland 2024-03-28
(Applies to server-side rulesets for core 4.2.36+)
Retrieves a file based on its file identifier from the document storage system. This function is exclusively available in server-side rulesets and is particularly useful for operations requiring file data access, such as reading content or processing file metadata.
Syntax
ft3.getFile(fileNo)
Part | Description |
---|---|
fileNo | Identifier of the file to be retrieved |
Returns
A promise that resolves to an object containing the file reference and the data associated with the file. The file reference includes the file number, file name, file type, and the base path where the file is stored. The data is provided in a Buffer
format, suitable for further processing or conversion as needed.
Example
ft3.getFile('8b2d7588-a03d-408f-8672-4d3aca41b90d').then(result => {
console.log(result.fileReference.fileName);
}).catch(err => {
console.error(err.message);
});
Sample Output
On successful execution, the output will be an object that includes details about the file and its content in a buffer. For example:
{
"fileReference": {
"fileNo": "8b2d7588-a03d-408f-8672-4d3aca41b90d",
"fileName": "sample.txt",
"fileType": "TXT",
"basePath": "20240301"
},
"data": {
"type": "Buffer",
"data": [
83,
71,
86,
115,
98,
71,
56,
115,
73,
70,
100,
118,
99,
109,
120,
107,
73,
81,
61,
61
]
}
}