Closed TRYOKETHEPEN closed 1 month ago
const myStorage = new Storage(myCfg) and const logStorage = new LogStorage() are my implementations. You can look at the LogStorage code and implement your own corresponding methods.
const myStorage = new Storage(myCfg) and const logStorage = new LogStorage() are my implementations. You can look at the LogStorage code and implement your own corresponding methods.
Thanks for reply! I'm new to JS, it's hard to me to develop new implement. I just want to use this project to convert model format for now.
From a cursory analysis of the code, I get that: (maybe useful for others)
Now my "debug.js" is simplified as:
import { ExporterWorker } from "./handler.js";
import { Storage } from './storage.js';
import { FileSource } from "./engine/main.js";
const myCfg = {
"callback_url": "http://127.0.0.1:1901/test1", //the converted model data POST to this url
"callback_file": true //use axios to POST
}
const myStorage = new Storage(myCfg)
const exporterWorker = new ExporterWorker(myStorage)
var data = {
gid: "debug", // use to identify, can be random
request_id: "1", // use to identify, can be random
urlType: FileSource.File, //input model's source
url: "./testfiles/stp/test.stp", //input model's data
file_name: "test.stp", //input model's name
convert_type: "glb", //convert type
}
exporterWorker.export(data)
Now my problem is: After "node debug.js", I get req.file=undefined at http server. The server is:
const express = require("express");
const multer = require("multer");
const cors = require("cors");
const app = express();
const upload = multer({ dest: "uploads/" });
app.use(cors());
app.post("/test1", upload.single("file"), (req, res) => {
const file = req.file;
console.log("recv file: ", file);
res.send({
code: 200,
data: "ok",
});
});
app.listen(1901, () => {
console.log("listen 1901");
});
It seems that form.append("file", file) has some problem unexpected:
I also tried to save converted model file locally. And I've checked the "model.glb" file I got, it is OK:
I have fixed the code 'form.append("file", file, gid + ".glb")'. Please try again
I have fixed the code 'form.append("file", file, gid + ".glb")'. Please try again
Thanks! The problem is resolved
Thanks for this project, I wonder how to get converted model file?
In "debug.js", defaultly use "LogStorage", it only print logs. So I changed "debug.js" as follow, to get the converted model file:
Then I build a http server at localhost, listening to "http://127.0.0.1:1901/test1", and the method is "POST". Then I excute "node debug.js":
When I set myCfg.callback_file = true : The client result is:
The server result is:
The problem is that I can't find the converted model file anywhere in localhost.
When I set myCfg.callback_file = false: The client result is:(raise error)
TypeError: source.on is not a function at Function.DelayedStream.create (/home/projects/step2glb/node_modules/delayed-stream/lib/delayed_stream.js:33:10) at FormData.CombinedStream.append (/home/projects/step2glb/node_modules/combined-stream/lib/combined_stream.js:45:37) at FormData.append (/home/projects/step2glb/node_modules/form-data/lib/form_data.js:75:3) at file:///home/projects/step2glb/storage.js:61:26 at ObjectUploader. (/home/projects/step2glb/node_modules/minio/dist/main/object-uploader.js:65:7)
at ObjectUploader.emit (node:events:377:35)
at emitErrorNT (node:internal/streams/destroy:193:8)
at emitErrorCloseNT (node:internal/streams/destroy:158:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
root@AIServer:/home/projects/step2glb# npm list demo@1.0.0 /home/projects/step2glb ├── axios@1.3.4 ├── draco3d@1.5.6 ├── express@4.18.2 ├── fflate@0.7.4 ├── formidable@2.1.1 ├── minio@7.0.33 ├── multer@1.4.5-lts.1 ├── occt-import-js@0.0.15 ├── rhino3dm@7.15.0 ├── three@0.150.1 └── web-ifc@0.0.39
root@AIServer:/home/projects/step2glb# node -v v16.2.0