我正在尝试使用C#
代码从 Vault(Vault 2015 SDK)下载文件。尝试了与此处提到的完全相同的方法:http:
//inventorhub.autodesk.com/discussions/threads/301/post/5600165
但出现错误
在执行下载文件的相应代码行时,请求失败,HTTP 状态为 404:未找到”。
请在下面找到我的示例代码:
using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Connectivity.WebServices;
UserPasswordCredentials login = new UserPasswordCredentials("servername", "myVault", "username", "Password", true);
using (WebServiceManager serviceManager = new WebServiceManager(login))
{
Autodesk.Connectivity.WebServices.Folder folder = serviceManager.DocumentService.GetFolderByPath("$/Myfolder");
Autodesk.Connectivity.WebServices.File[] files = serviceManager.DocumentService.GetLatestFilesByFolderId(folder.Id, false);
if (files != null && files.Any())
{
foreach (Autodesk.Connectivity.WebServices.File file in files)
{
//Sample code to download the files
string localPath = AppDomain.CurrentDomain.BaseDirectory;
Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
var FileDownloadTicket = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { file.Id });
FilestoreService fileStoreService = new FilestoreService();
var fileBytes = fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
System.IO.File.WriteAllBytes(localPath, fileBytes);
}
}
}
得到错误fileStoreService.DownloadFilePart(FileDownloadTicket[0].Bytes, 0, localFile.FileSize, false);
。我可以手动下载文件,但不能以编程方式下载。我究竟做错了什么 ?如果我能获得一些示例代码来下载基于元数据的文件,那就太好了。
谢谢!