从 AutoDesk Vault (Vault 2015 SDK) 下载文件时出现 c# 代码错误

Download File from AutoDesk Vault (Vault 2015 SDK) with c# code giving error

我正在尝试使用 C# 代码从 Vault (Vault 2015 SDK) 下载文件。尝试了与此处提到的完全相同的方法: http://inventorhub.autodesk.com/discussions/threads/301/post/5600165 但出现错误

The request failed with HTTP status 404: Not Found" while executing the respective line of code for downloading the file.

请在下面找到我的示例代码:

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); 收到错误。 我可以手动下载文件,但不能以编程方式下载。我究竟做错了什么 ? 如果我能得到一些示例代码来根据元数据下载文件,那就太好了。

谢谢!

要下载您想要的文件"Acquire"。

查看对象的 SDK 文档: Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection

创建连接对象后,使用它来获取文件(注意这也是您签出文件的方式):

using VDF = Autodesk.DataManagement.Client.Framework;

var acquireSettings = new VDF.Vault.Settings.AcquireFilesSettings(
    connection, updateFileReferences: false);

foreach (var file in files)
{
    acquireSettings.AddFileToAcquire(
        new VDF.Vault.Currency.Entities.FileIteration(connection, file),
        VDF.Vault.Settings.AcquireFilesSettings.AcquisitionOption.Download);
}

VDF.Vault.Results.AcquireFilesResults results = connection.FileManager.AcquireFiles(acquireSettings);

我修改了

FilestoreService fileStoreService = new FilestoreService()

FilestoreService fileStoreService = serviceManager.FilestoreService

在问题中发布的代码片段中,它起作用了。