You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否使用AZCopy将Autodesk Construction Cloud文件迁移至Azure Storage?

将Autodesk Construction Cloud(ACC)文件复制到Azure Storage:AZCopy支持情况及解决方案

AZCopy不直接支持从Autodesk Construction Cloud(ACC)到Azure Storage的文件传输,它原生仅支持本地文件系统、Azure云服务(Blob/File/ADLS)、AWS S3、Google Cloud Storage等少数源,ACC不在其内置支持的源列表中。

可行解决方案

基于你已经能通过ACC API读取文件夹内容的基础,有两种常用实现方式:

方案1:先下载ACC文件到本地,再用AZCopy上传到Azure Storage

这种方式利用AZCopy的断点续传、并发传输优势,适合大文件场景:

  1. 通过ACC API获取目标文件的下载链接
  2. 将文件下载到本地临时目录
  3. 调用AZCopy命令完成上传

结合你的代码,补充实现示例:

var contentsEndpoint = $"https://developer.api.autodesk.com/data/v1/projects/{projectId}/folders/{folderID}/contents";
var request = new HttpRequestMessage(HttpMethod.Get, contentsEndpoint);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

var response = await _httpClient.SendAsync(request);
var responseString = await response.Content.ReadAsStringAsync();
JObject jsonObject = JObject.Parse(responseString);
JArray array2 = (JArray)jsonObject["data"];

foreach (var item in array2)
{
    if (item["type"].ToString() == "items" && item["attributes"]["displayName"].ToString() == "signature.jpg")
    {
        var itemId = item["id"].ToString();
        // 1. 获取ACC文件的下载链接
        var downloadEndpoint = $"https://developer.api.autodesk.com/data/v1/projects/{projectId}/items/{itemId}/download";
        var downloadRequest = new HttpRequestMessage(HttpMethod.Get, downloadEndpoint);
        downloadRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
        var downloadResponse = await _httpClient.SendAsync(downloadRequest);

        if (downloadResponse.IsSuccessStatusCode)
        {
            // 2. 下载文件到本地临时路径
            var tempFilePath = Path.Combine(Path.GetTempPath(), "signature_temp.jpg");
            using (var stream = await downloadResponse.Content.ReadAsStreamAsync())
            using (var fileStream = new FileStream(tempFilePath, FileMode.Create))
            {
                await stream.CopyToAsync(fileStream);
            }

            // 3. 调用AZCopy上传到Azure Storage
            var azcopyCmd = $"copy \"{tempFilePath}\" \"https://<your-storage-account>.blob.core.windows.net/<your-container>/signature.jpg?<your-sas-token>\"";
            var processStartInfo = new ProcessStartInfo("azcopy", azcopyCmd)
            {
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };

            using (var process = Process.Start(processStartInfo))
            {
                process.WaitForExit();
                // 可根据需要处理AZCopy的输出和错误信息
                var output = await process.StandardOutput.ReadToEndAsync();
                var error = await process.StandardError.ReadToEndAsync();
            }

            // 清理临时文件
            File.Delete(tempFilePath);
        }
    }
}

方案2:直接流式传输到Azure Storage(无需本地文件)

这种方式无需占用本地磁盘空间,适合小文件或内存充足的场景,直接通过代码完成端到端传输:

// 需先安装Azure.Storage.Blobs NuGet包
using Azure.Storage.Blobs;

// ... 你的原有代码 ...

foreach (var item in array2)
{
    if (item["type"].ToString() == "items" && item["attributes"]["displayName"].ToString() == "signature.jpg")
    {
        var itemId = item["id"].ToString();
        var downloadEndpoint = $"https://developer.api.autodesk.com/data/v1/projects/{projectId}/items/{itemId}/download";
        var downloadRequest = new HttpRequestMessage(HttpMethod.Get, downloadEndpoint);
        downloadRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
        var downloadResponse = await _httpClient.SendAsync(downloadRequest);

        if (downloadResponse.IsSuccessStatusCode)
        {
            // 直接将ACC文件流上传到Azure Blob Storage
            var blobServiceClient = new BlobServiceClient("<your-azure-storage-connection-string>");
            var containerClient = blobServiceClient.GetBlobContainerClient("<your-container>");
            var blobClient = containerClient.GetBlobClient("signature.jpg");

            using (var fileStream = await downloadResponse.Content.ReadAsStreamAsync())
            {
                await blobClient.UploadAsync(fileStream, overwrite: true);
            }
        }
    }
}

方案对比

  • 方案1:优势是AZCopy自带断点续传、多线程优化,大文件传输更稳定;缺点是需要本地临时存储。
  • 方案2:优势是无需本地磁盘,代码集成度更高;缺点是大文件传输需自行处理断点续传等逻辑。

内容的提问来源于stack exchange,提问作者Vijay Kumbhoje

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 12:50:59