Download file from Autodesk Forge 3D viewer

被刻印的时光 ゝ 提交于 2019-12-24 11:24:56

问题


How do I download a file from the 3D viewer in Autodesk Forge. I am using 2 legged authorization and I am able to upload files to the bucket, but I am not sure how to download the file from them in the 3D viewer. The code below downloads files but there is nothing contained inside them:

var element = document.createElement('a');
element.setAttribute('href', '#');
element.setAttribute('download', node.text);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);

I have looked at this link as a reference but I don't understand how to convert this into code inside Javascript or .NET: https://forge.autodesk.com/en/docs/data/v2/tutorials/download-file/


回答1:


I am able to download files now, from Javascript use $.ajax with the url path to the method in .NET then use:

WebClient client = new WebClient();
Uri address = new Uri(storageLocation);
fileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + fileName;
client.Headers.Add("Content-Type", "application/octet-stream");
client.Headers.Add("Authorization", "Bearer " + credentials.TokenInternal);
client.DownloadFileAsync(address, fileName);
return client;

This will download files to the desktop.




回答2:


You can also try this endpoint:

https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-:bucketKey-objects-:objectName-GET/

It will download an object from the Bucket location you specify.

This is a REST endpoint you can check both the NPM or NuGet we have to see if that function is already available. In case is not please submit a request to be include it.



来源:https://stackoverflow.com/questions/53597179/download-file-from-autodesk-forge-3d-viewer

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