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/
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.
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.