jbilcke-hf HF staff commited on
Commit
50725ac
1 Parent(s): 048dcb2
Files changed (3) hide show
  1. package-lock.json +18 -0
  2. package.json +1 -0
  3. src/index.mts +5 -2
package-lock.json CHANGED
@@ -12,6 +12,7 @@
12
  "@gorgonjs/file-provider": "^1.4.1",
13
  "@gorgonjs/gorgon": "^1.4.1",
14
  "@types/express": "^4.17.17",
 
15
  "@types/uuid": "^9.0.2",
16
  "archiver": "^6.0.1",
17
  "axios": "^1.5.1",
@@ -126,6 +127,14 @@
126
  "@types/node": "*"
127
  }
128
  },
 
 
 
 
 
 
 
 
129
  "node_modules/@types/connect": {
130
  "version": "3.4.36",
131
  "license": "MIT",
@@ -143,6 +152,15 @@
143
  "@types/serve-static": "*"
144
  }
145
  },
 
 
 
 
 
 
 
 
 
146
  "node_modules/@types/express-serve-static-core": {
147
  "version": "4.17.36",
148
  "license": "MIT",
 
12
  "@gorgonjs/file-provider": "^1.4.1",
13
  "@gorgonjs/gorgon": "^1.4.1",
14
  "@types/express": "^4.17.17",
15
+ "@types/express-fileupload": "^1.4.2",
16
  "@types/uuid": "^9.0.2",
17
  "archiver": "^6.0.1",
18
  "axios": "^1.5.1",
 
127
  "@types/node": "*"
128
  }
129
  },
130
+ "node_modules/@types/busboy": {
131
+ "version": "1.5.1",
132
+ "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-1.5.1.tgz",
133
+ "integrity": "sha512-JAymE2skNionWnBUwby3MatzPUw4D/6/7FX1qxBXLzmRnFxmqU0luIof7om0I8R3B/rSr9FKUnFCqxZ/NeGbrw==",
134
+ "dependencies": {
135
+ "@types/node": "*"
136
+ }
137
+ },
138
  "node_modules/@types/connect": {
139
  "version": "3.4.36",
140
  "license": "MIT",
 
152
  "@types/serve-static": "*"
153
  }
154
  },
155
+ "node_modules/@types/express-fileupload": {
156
+ "version": "1.4.2",
157
+ "resolved": "https://registry.npmjs.org/@types/express-fileupload/-/express-fileupload-1.4.2.tgz",
158
+ "integrity": "sha512-m7j9veuCI02m0eyMfmZI7jrVU2CzH43U6EbAuzvCoBdhliXdIndb32cukcRTG4AOQONbe0MBmEcWvXAmQh9IMg==",
159
+ "dependencies": {
160
+ "@types/busboy": "*",
161
+ "@types/express": "*"
162
+ }
163
+ },
164
  "node_modules/@types/express-serve-static-core": {
165
  "version": "4.17.36",
166
  "license": "MIT",
package.json CHANGED
@@ -15,6 +15,7 @@
15
  "@gorgonjs/file-provider": "^1.4.1",
16
  "@gorgonjs/gorgon": "^1.4.1",
17
  "@types/express": "^4.17.17",
 
18
  "@types/uuid": "^9.0.2",
19
  "archiver": "^6.0.1",
20
  "axios": "^1.5.1",
 
15
  "@gorgonjs/file-provider": "^1.4.1",
16
  "@gorgonjs/gorgon": "^1.4.1",
17
  "@types/express": "^4.17.17",
18
+ "@types/express-fileupload": "^1.4.2",
19
  "@types/uuid": "^9.0.2",
20
  "archiver": "^6.0.1",
21
  "axios": "^1.5.1",
src/index.mts CHANGED
@@ -33,7 +33,7 @@ app.post("/", async (req: Request, res: Response, _next: NextFunction) => {
33
  }
34
 
35
  const options: ColmapOptions = req.body;
36
- let dataFile: fileUpload.UploadedFile | string = "";
37
 
38
  try {
39
  // we accept either JSON requests
@@ -95,7 +95,7 @@ function setupDirectories() {
95
  return { projectTempDir, outputTempDir, imageFolder };
96
  }
97
 
98
- async function handleFileStorage(dataFile: fileUpload.UploadedFile | string, projectTempDir: string) {
99
  console.log(`handleFileStorage called (projectTempDir: ${projectTempDir})`);
100
  console.log("typeof dataFile: " + typeof dataFile);
101
  if (dataFile instanceof Buffer) {
@@ -104,6 +104,9 @@ async function handleFileStorage(dataFile: fileUpload.UploadedFile | string, pro
104
  } else if (typeof dataFile === "object" && dataFile.mv) {
105
  console.log(`typeof dataFile === "object" && dataFile.mv`);
106
  try {
 
 
 
107
  await dataFile.mv(path.join(projectTempDir, dataFile.name));
108
  } catch (error) {
109
  throw new Error(`File can't be moved: ${error}`);
 
33
  }
34
 
35
  const options: ColmapOptions = req.body;
36
+ let dataFile: fileUpload.UploadedFile | Buffer = Buffer.from("");
37
 
38
  try {
39
  // we accept either JSON requests
 
95
  return { projectTempDir, outputTempDir, imageFolder };
96
  }
97
 
98
+ async function handleFileStorage(dataFile: fileUpload.UploadedFile | Buffer, projectTempDir: string) {
99
  console.log(`handleFileStorage called (projectTempDir: ${projectTempDir})`);
100
  console.log("typeof dataFile: " + typeof dataFile);
101
  if (dataFile instanceof Buffer) {
 
104
  } else if (typeof dataFile === "object" && dataFile.mv) {
105
  console.log(`typeof dataFile === "object" && dataFile.mv`);
106
  try {
107
+ console.log("dataFile.name = " + dataFile.name);
108
+
109
+ console.log("path.join(projectTempDir, dataFile.name) = " + path.join(projectTempDir, dataFile.name));
110
  await dataFile.mv(path.join(projectTempDir, dataFile.name));
111
  } catch (error) {
112
  throw new Error(`File can't be moved: ${error}`);