问题
I am trying to upload some models to the Autodesk Forge Data Management API. Unfortunately, the models are 1GB+ in size and the API gives a timeout exception:
StatusCode: 504, ReasonPhrase: 'GATEWAY_TIMEOUT'
Using the following code (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;
}
Do you have any suggestions? Thanks in advance!
回答1:
That's expected, you should use resumable upload for files larger than 100Mb (as per documentation).
Check this sample using the Autodesk.Forge .NET package.
回答2:
Cause error 416 when uploading large file with the forge-bucketsmanager-desktop.
Please check this issue.
- https://github.com/Autodesk-Forge/forge-bucketsmanager-desktop/issues/12
来源:https://stackoverflow.com/questions/52892577/upload-large-files-2gb-to-autodesk-forge-data-management-api