Get files from the directory specified
This instance is an example for demonstrations, see more about the configuration here
ts
const fupinstance = new FupNode({
path: "uploads",
});This function allows you to read the specified file and prevents reverse path attack.
ts
async function getFile(
// Name of the file to read from the directory specified
name: string
): Promise<Buffer>; // Buffer returned from file readedExample usage
ts
const bufferFile = await fupinstance.getFile("file.txt");Error handling
About the error: The name of the file is invalid.
- message -> Invalid file name:
name name= It is the name of the specified file.
About the error: Error file don't exist.
- message -> File
namedon't exist! name= It is the name of the specified file.
