How to get the file blob or whatever to feed into file-type's fileTypeFromFile

Hi, I’m trying to create a server side function to validate the file type to prevent any malicious file upload but I don’t know what to feed into fileTypeFromFile. the path is empty.

import { Plugin } from '@nocobase/server';
import { fileTypeFromFile } from 'file-type';

export default class FileValidation extends Plugin {
    async load() {
        this.db.on('file.afterCreate', async (model: any, options: any) => {
            const allowedMimeTypes = new Set([
                'image/jpeg',
                'image/png',
                'image/webp',
                'application/pdf',
                'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
                'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            ]);

            const mimeType = model.get('mimetype')

            // Do not trust the MIME type supplied by the client.
            const filePath = options.values.path
            console.log('path: ', filePath)

            if (!filePath) {
                throw new Error('Cannot validate uploaded file');
            }

            const detected = await fileTypeFromFile(filePath);
            console.log('detected: ', detected.mime)

            if (!detected || !allowedMimeTypes.has(detected.mime)) {
                throw new Error('This file type is not allowed');
            }

            // Compare declared MIME type with detected MIME type.
            if (mimeType !== detected.mime) {
                throw new Error('File MIME type does not match its contents');
            }
        });
    }
}

Set File types on the storage engine (MIME patterns such as image/jpeg,image/png,application/pdf). NocoBase already runs file-type’s fileTypeFromBuffer over the first 4 KB of the upload before persisting, stores the detected MIME type instead of the client-supplied one, and rejects a mismatch with HTTP 400. That covers your allow-list and the MIME/content comparison in one configuration step. Docs: NocoBase Documentation

thank you