npm i sequelize-db-storage-files
import { DbStorageFiles } from "sequelize-db-storage-files";
import { Sequelize } from "sequelize-typescript";
const sequelize = new Sequelize({
// ... options
});
const dbStorageFiles = new DbStorageFiles(sequelize);
await sequelize.sync();
const file = await dbStorageFiles.write('/text.txt', Buffer.from('Hello, World!'));
const file = await dbStorageFiles.getFromPath('/text.txt');
if(!file) throw new Error("Not found File");
const text = (await file.getFileData()).data.toString('utf-8');
console.log(text); // Hello, World!
file.id // string(uuidv4)
file.z // string
file.hash // string (sha256)
file.info // string (json)
file.size // number (bytes)
file.deletionDate // Date | null
file.createdAt // Date
file.updatedAt // Date
DbStorageFile
and DbStorageFileData
are sequelize models, so all the methods in the sequelize documentation apply to them