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