【发布时间】:2018-01-18 19:35:26
【问题描述】:
在最近使用 extract.autodesk.io 模块 (SVF model derivative downloaded as an (almost) empty ZIP file (Autodesk Forge)) 解决的帖子之后,我仍然无法仅使用官方 forge 下载 SVF 模型衍生品-apis 模块,在 2 足环境中。
这是我试图实现的最小示例:
var ForgeSDK = require("forge-apis");
/* The next four lines are filled with my credentials and URN values
* (this shouldn't be the problem, since getting the manifest for the URN
* is performed successfully) */
var client_id = "...";
var client_secret = "...";
var urn = "...";
var derivative_urn = "...";
var derivatives = new ForgeSDK.DerivativesApi();
var autoRefresh = true;
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(client_id,
client_secret, [
"data:read", "data:write", "bucket:read", "bucket:write"
], autoRefresh);
oAuth2TwoLegged.authenticate().then(function(credentials) {
derivatives.getDerivativeManifest(urn, derivative_urn, {}, credentials, oAuth2TwoLegged).then(function(content) {
console.log(content);
}).catch(function(err) {
if (err) {
console.log(err);
}
})
});
我收到以下错误:{ statusCode: 401, statusMessage: 'Unauthorized' }。是范围问题吗?
提前非常感谢!
PS:我知道 extract.autodesk.io 提供了一个很好的方法来做到这一点,但我觉得使用 bubble 对象并不是那么简单的转置另一个上下文。 forge-apis 模块应该可以无缝地完成这项工作(或者我遗漏了一些东西)。
更新:按照 Augusto 的建议,我使用了最基本的命令(即 cUrl)从 IFC 文件中下载信息。下面的前两个命令成功运行(下载清单和 PNG 屏幕截图文件)。 SVF 的下载似乎也可以正常工作,只是 ZIP 文件只包含两个 JSON 文件(manifest.json 和 metadata.json),以及三个空目录(几何、材质、场景)。
代码如下:
# Get manifest for the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest" > manifest.json
# Get a PNG related to the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest/$URN_PNG" > image.png
# Get the SVF converted from the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest/$URN_SVF" > output.zip
有什么想法吗?
【问题讨论】:
-
这似乎是一个您看不到的 URN/Bucket,您可以使用 Postman(或类似工具)在该端点上尝试一个简单的 GET 吗?
-
感谢奥古斯托的建议。我已经在编辑中回答了(见更新)。
-
谢谢@Rajan,我会检查代码,但你能确认一下包版本 0.4.1 吗?我知道我们最近做了一些修复。 npmjs.com/package/forge-apis
-
是的,我用的是0.4.1版本的forge-apis。感谢您的帮助。
标签: node.js autodesk-forge autodesk-model-derivative