uploaded-file-saver
v1.0.1
Published
Saves, updates and deletes uploaded files from hard drive.
Downloads
12
Maintainers
Readme
uploaded-file-saver
Saves, updates and deletes uploaded files to and from the hard drive.
Installation:
npm i uploaded-file-saver
Usage:
- Config once a common containing folder for all files (note that on each save/update/delete you can specify a different folder than this one):
import { fileSaver } from "uploaded-file-saver";
import path from "path";
fileSaver.config(path.join(__dirname, "..", "my-assets", "my-uploaded-files"));
- Save an uploaded file:
const createdFileName = await fileSaver.add(myUploadedFile);
- Update existing file with a new uploaded one:
const updatedFileName = await fileSaver.update(existingFileName, newUploadedFile);
- Delete existing file:
await fileSaver.delete(existingFileName);
- Get existing file path:
const filePath = fileSaver.getFilePath(existingFileName);
- Get a cool file-not-found path:
const filePath = fileSaver.getFileNotFoundPath();