How do I display a thumbnail that has been generated after translation

不问归期 提交于 2021-02-11 07:00:09

问题


After translating a file to SVF I can see that there is thumbnails that have been generated. How do I use the URN to display these thumbnails?

Thanks!


回答1:


You can use the Thumbnail endpoint to download the picture, but it requires the Token. So you can, for instance, download it on your server-side (with the token) and redirect the stream to the client-side (from your server).

Here is the thumbnail endpoint: '/modelderivative/' + MD_PROJECT_VERSION + '/designdata/' + urn + '/thumbnail?width=XXX&height=XXX';

And an example (NodeJS)

getThumbnail: function (thumbnailUrn, onsuccess){
    request({
        url: '/modelderivative/v2/designdata/' + thumbnailUrn + '/thumbnail?width=100&height=100';,
        method: "GET",
        headers: {
            'Authorization': 'Bearer ' + token
        },
        encoding: null
    }, function (error, response, body) {
        onsuccess(new Buffer(body, 'base64'));
    });
},

And an NodeJS router:

router.get('/thumbnail', function (req, res) {
   getThumbnail(req.query.urn, function (thumb) {
        res.setHeader('Content-type', 'image/png');
        res.end(thumb);
    });
});

Finally at your HTML you can just use:

<img src="/thumbnail?urn=XxXxXxXxX">


来源:https://stackoverflow.com/questions/38364497/how-do-i-display-a-thumbnail-that-has-been-generated-after-translation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!