从 Autodesk Forge 3D 查看器下载文件 [英] Download file from Autodesk Forge 3D viewer
问题描述
如何从 Autodesk Forge 中的 3D 查看器下载文件.我使用的是 2 条腿授权,我可以将文件上传到存储桶,但我不确定如何在 3D 查看器中从它们下载文件.下面的代码下载文件,但里面没有任何内容:
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);
我已将此链接视为参考,但我不明白如何将其转换为 Javascript 或 .NET 中的代码:https://forge.autodesk.com/en/docs/data/v2/tutorials/download-file/
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/
推荐答案
我现在可以下载文件,从 Javascript 使用 $.ajax
和 url
路径到.NET 中的方法然后使用:
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.
这篇关于从 Autodesk Forge 3D 查看器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!