Forge Design Automation Revit教程错误

发布于 2025-02-02 03:44:57 字数 1953 浏览 4 评论 0原文

我正在尝试设计自动化教程进行修订。 我遇到以下错误。 有人可以帮助我解决此错误。

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of ReadStream
at new NodeError (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\internal\errors.js:372:5)
at write_ (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\_http_outgoing.js:742:11)
at ClientRequest.end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\_http_outgoing.js:855:5)
at Request._end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\node\index.js:1282:9)
at Request.end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\node\index.js:1000:8)
at c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\request-base.js:282:12
at new Promise (<anonymous>)
at RequestBase.then (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\request-base.js:264:31)
at c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\forge-apis\src\ApiClient.js:394:7
at processTicksAndRejections (node:internal/process/task_queues:96:5) {code: 'ERR_INVALID_ARG_TYPE', statusCode: undefined, stack: 'TypeError [ERR_INVALID_ARG_TYPE]: The "chunk"…ions (node:internal/process/task_queues:96:5)', message: 'The "chunk" argument must be of type string …nt8Array. Received an instance of ReadStream', toString: ƒ, …}

I am trying the Design Automation Tutorial for Revit.
I am getting the following error.
Can someone help me fix this error.

enter image description here

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of ReadStream
at new NodeError (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\internal\errors.js:372:5)
at write_ (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\_http_outgoing.js:742:11)
at ClientRequest.end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\lib\_http_outgoing.js:855:5)
at Request._end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\node\index.js:1282:9)
at Request.end (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\node\index.js:1000:8)
at c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\request-base.js:282:12
at new Promise (<anonymous>)
at RequestBase.then (c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\superagent\lib\request-base.js:264:31)
at c:\Users\roshan.kerketta\Desktop\Digital\Forge\ModelDesignAutomation\SampleDesignAutomation\node_modules\forge-apis\src\ApiClient.js:394:7
at processTicksAndRejections (node:internal/process/task_queues:96:5) {code: 'ERR_INVALID_ARG_TYPE', statusCode: undefined, stack: 'TypeError [ERR_INVALID_ARG_TYPE]: The "chunk"…ions (node:internal/process/task_queues:96:5)', message: 'The "chunk" argument must be of type string …nt8Array. Received an instance of ReadStream', toString: ƒ, …}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

书信已泛黄 2025-02-09 03:44:57

感谢拉胡尔发现这个问题!我可以重现@johnkuldeeproshankerketta在0.9.0中以Forge SDK(Forge-apis)经历的内容。根据错误的提示,我更新了教程代码(第509,510行)使用readfile而不是文件流。现在,它可以与0.9.0合作。

我发布了教程的问题
https://github.com/autodesk-forge/learn.forge。 DesignAutomation/Essue/31

// 2. upload inputFile
const inputFileNameOSS = `${new Date().toISOString().replace(/[-T:\.Z]/gm, '').substring(0,14)}_input_${_path.basename(req.file.originalname)}`; // avoid overriding

try {
    //let contentStream = _fs.createReadStream(req.file.path);

    let fileContent = _fs.readFileSync(req.file.path);

    await new ForgeAPI.ObjectsApi().uploadObject(bucketKey, inputFileNameOSS, req.file.size, fileContent, {}, req.oauth_client, req.oauth_token);
}

Thanks Rahul for spotting the issue! I can reproduce what @JohnKuldeepRoshanKerketta experienced in Forge SDK (forge-apis) in 0.9.0. By the hint of error, I updated the tutorial code(line 509,510) to use readFile, instead of file stream. Now it works well with 0.9.0.

I posted the Issue with tutorial
https://github.com/Autodesk-Forge/learn.forge.designautomation/issues/31

// 2. upload inputFile
const inputFileNameOSS = `${new Date().toISOString().replace(/[-T:\.Z]/gm, '').substring(0,14)}_input_${_path.basename(req.file.originalname)}`; // avoid overriding

try {
    //let contentStream = _fs.createReadStream(req.file.path);

    let fileContent = _fs.readFileSync(req.file.path);

    await new ForgeAPI.ObjectsApi().uploadObject(bucketKey, inputFileNameOSS, req.file.size, fileContent, {}, req.oauth_client, req.oauth_token);
}
演出会有结束 2025-02-09 03:44:57

我想了解错误的含义,因此可以帮助我解决错误。尽管它可能是基本的。

如果您的目标是了解此特定错误,那么您可以阅读此问题/答案最好/解释。但是,由于这来自Forge的nodejs apis,因此我认为您没有编写此代码,因此您不应该关注它。

我最好的猜测是,您已经设法升级了nodejs package forge-api 0.9.0和其他教程repo/code的其余部分与它不兼容。您可以使用以下命令进行检查:

cd {repo_folder}
npm ls -depth=0

您应该查看以下结果:

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

如果您的forge-apis正在显示0.9.0而不是0.8.6 0.8.6 ,然后说明您遇到的错误。要降级它,您可以删除node_modules文件夹,请删除对package.json.json和/或package> package> package-lock.json的任何更改,然后运行npm安装

另外,您也可以明确降级forge-api模块。

cd {repo_folder}
npm install [email protected] -save
npm ls -depth=0

I want to understand what the error means, so it could help me fix the error., though it might be basic.

If your goal is to understand this specific error, then you can read this question/answer where it is best asked/explained. However since this is coming from Forge's nodejs apis, I think you did not write this code and you should not be concerned with it.

My best guess is you have somehow managed to upgrade the nodejs package forge-api to 0.9.0 and the rest of the tutorial repo/code is not compatible with it. You can check this with the following command:

cd {repo_folder}
npm ls -depth=0

You should see the following result:

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

If your forge-apis is showing 0.9.0 instead of 0.8.6, then it explains the error you have. To downgrade it, you can either delete your node_modules folder, undo any changes to package.json and/or package-lock.json and run npm install again.

Alternatively you can also explicitly downgrade the forge-api module.

cd {repo_folder}
npm install [email protected] -save
npm ls -depth=0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文