问题
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