将大文件 (2GB) 上传到 Autodesk Forge Data Management API

Upload large files (2GB) to Autodesk Forge Data Management API

我正在尝试将一些模型上传到 Autodesk Forge 数据管理 API。不幸的是,模型的大小为 1GB+,API 给出了超时异常:

StatusCode: 504, ReasonPhrase: 'GATEWAY_TIMEOUT'

使用以下代码 (C#):

var url = $"https://developer.api.autodesk.com/oss/v2/buckets/{bucketKey}/objects/{objectName}";

        using (var httpClient = GetAuthorizedHttpClient("data:write"))
        {
            httpClient.Timeout = TimeSpan.FromMinutes(120);
            var request = new HttpRequestMessage(HttpMethod.Put, url);

            fileStream.Position = 0;

            request.Content = new StreamContent(fileStream);                

            var response = httpClient.SendAsync(request).Result;

            var responseContent = response.Content.ReadAsStringAsync().Result;

            if (!response.IsSuccessStatusCode)
                throw new Exception($"Failed to upload object: {response.ReasonPhrase}");

            var result = JsonConvert.DeserializeObject<ObjectUploadResult>(response.Content.ReadAsStringAsync().Result);
            return result;
        }

你有什么建议吗? 提前致谢!

这是预料之中的,您应该对大于 100Mb 的文件使用断点续传(根据 documentation)。

检查this sample using the Autodesk.Forge .NET package

使用 forge-bucketsmanager-desktop.
上传大文件时导致错误 416 请检查此问题。