从 Autodesk Forge 3D 查看器下载文件 [英] Download file from Autodesk Forge 3D viewer

查看:25
本文介绍了从 Autodesk Forge 3D 查看器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 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 使用 $.ajaxurl 路径到.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆