feat: form middleware
This commit is contained in:
parent
808690c486
commit
9180fecdfb
@ -12,7 +12,7 @@ if (!host) {
|
||||
process.exit(1);
|
||||
}
|
||||
const app = express();
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
const formMiddleware = express.urlencoded({ extended: true });
|
||||
|
||||
/**
|
||||
* @typedef {import("@awo00/smb2/dist/client/Session").default} Session
|
||||
@ -22,7 +22,7 @@ app.use(express.urlencoded({ extended: true }));
|
||||
*/
|
||||
const sessionPool = new SessionPool(60000);
|
||||
|
||||
app.post("/", async (req, res) => {
|
||||
app.post("/", formMiddleware, async (req, res) => {
|
||||
try {
|
||||
const username = req.body.username;
|
||||
const password = req.body.password;
|
||||
@ -101,10 +101,10 @@ app.post("/:sessionId/:shareName/*", async (req, res) => {
|
||||
res.end();
|
||||
} else {
|
||||
// Create a write stream to the destination file
|
||||
if (!fileExists)
|
||||
await tree.createFile(filePath);
|
||||
if (fileExists)
|
||||
await tree.removeFile(filePath);
|
||||
const writeStream = await tree.createFileWriteStream(filePath);
|
||||
console.log("stream created")
|
||||
console.log("stream created");
|
||||
// Pipe the uploaded file to the write stream
|
||||
req.pipe(writeStream);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user