如何检查存储桶对象是否已翻译

发布于 2025-01-09 19:31:37 字数 56 浏览 0 评论 0原文

我已经将文件上传到oss并有对象id,如果存储桶对象尚未翻译,那么如何检查衍生信息。与对象 ID?

I've uploaded file to oss and have object id, if bucket object is not yet translated then how to check derivatives info. with object id?

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

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

发布评论

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

评论(1

狼亦尘 2025-01-16 19:31:37

这很简单,只需对您的 objectId 进行 Base64 编码,然后调用 获取 {urn}/manifest。如果它返回 404 http 状态代码,则表示此 URN 尚未转换。

如果您的文件存储在 BIM360/ACC 上,您将需要从文件的版本提示中获取派生 URN。请按照本教程进行操作,但找到 relationships.data.derivatives.data.id 而不是 URN,如下例所示。

https://forge.autodesk.com/en/docs/bim360/v1/tutorials/document-management/download-document/#step-4-find-the-storage-object-id-for-the- file

"derivatives": {
    "data": {
        "type": "derivatives",
        "id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkVueWtrU3FjU0lPVTVYMGhRdy1mQUM_dmVyc2lvbj0x"
    },
    // ...
},

使用 yiskang/forge-viewmodels-nodejs-svf2

const {
    DerivativesApi
} = require('forge-apis');

const { getClient, getPublicToken } = require('./routes/common/oauth');

const derivativeApi = new DerivativesApi();

const urn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXlidWNrZXQvdGVzdC5ydnQ';

getPublicToken().then(accessToken => {
    derivativeApi.getManifest(urn, {}, null, accessToken).then(function (res) {
        console.log(res.statusCode, res.statusMessage);
    },
    function (err) {
        // When the urn hasn't got translated, it goes here
        console.error('error', err.statusCode, err.statusMessage);
        // if you want to redire page to some where, write your codes here
    });
}, function (err) {
    console.error(err);
});

参考:https://stackoverflow.com/a/70664111/ 7745569

It's straightforward, just base64 encode your objectId, then call GET {urn}/manifest. If it returns a 404 http status code, then it means this URN hasn't got translated.

If your file is stored on BIM360/ACC, you will need to get derivative URN from the file's version tip. Please follow this tutorial, but find relationships.data.derivatives.data.id instead for the URN like the below for example.

https://forge.autodesk.com/en/docs/bim360/v1/tutorials/document-management/download-document/#step-4-find-the-storage-object-id-for-the-file

"derivatives": {
    "data": {
        "type": "derivatives",
        "id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLkVueWtrU3FjU0lPVTVYMGhRdy1mQUM_dmVyc2lvbj0x"
    },
    // ...
},

Node.js code sample tested with yiskang/forge-viewmodels-nodejs-svf2

const {
    DerivativesApi
} = require('forge-apis');

const { getClient, getPublicToken } = require('./routes/common/oauth');

const derivativeApi = new DerivativesApi();

const urn = 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bXlidWNrZXQvdGVzdC5ydnQ';

getPublicToken().then(accessToken => {
    derivativeApi.getManifest(urn, {}, null, accessToken).then(function (res) {
        console.log(res.statusCode, res.statusMessage);
    },
    function (err) {
        // When the urn hasn't got translated, it goes here
        console.error('error', err.statusCode, err.statusMessage);
        // if you want to redire page to some where, write your codes here
    });
}, function (err) {
    console.error(err);
});

ref: https://stackoverflow.com/a/70664111/7745569

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文