-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.js
More file actions
34 lines (26 loc) · 1009 Bytes
/
debug.js
File metadata and controls
34 lines (26 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require("node:fs")
const path = require("node:path")
const session_lib = require("./session.js");
exports.CreateSessionWithFileFixture = (plugin_config, request, filename) => {
const sourceFile = path.join(path.resolve(process.cwd()), "../../fixtures/", filename);
const targetFile = path.join(plugin_config.uploadPath, filename);
fs.copyFileSync(sourceFile, targetFile);
const fstats = fs.statSync(targetFile)
let encoding = "utf8";
let mimetype = "text/csv"
if (!filename.toLowerCase().endsWith(".csv")) {
encoding = "7bit";
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
}
request.file = {
fieldname: "file",
originalname: filename,
mimetype: mimetype,
encoding: encoding,
path: targetFile,
size: fstats.size,
destination: plugin_config.uploadPath,
filename: filename
};
return session_lib.CreateSession(plugin_config, request)
}