Code for uploading an rvt file with the Autodesk Data Management API API.
For small files I have no problem uploading, but when I want to upload a 46 MG file the program breaks.
I used curl in cmd to make these uploads, and I have not had any problem with the size of the files, Now that I want to automate the upload, with RestClient I get this error
I have tried to change / delete the "Content-Length" parameter in the call, but it still does not work.
Help, Thanks.
public static string Upload(string accessToken, string bucketName, string fileName, byte[] fileData)
{
var client = new RestClient();
client.BaseUrl = new System.Uri(baseApiUrl);
var request = new RestRequest();
request.Resource"oss/{version}/buckets/{bucketname}/objects/{filename}";
request.Method = Method.PUT;
request.AddUrlSegment("version", "v1");
request.AddUrlSegment("bucketname", bucketName);
request.AddUrlSegment("filename", fileName);
request.AddHeader("Authorization", "Bearer " + accessToken);
request.AddHeader("Content-Type", "application/octet-stream");
request.AddHeader("Content-Length", "48033792");
request.AddParameter("requestBody", fileData,ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
m_lastResponse = response;
// Get the id = "urn:xxx"
string id = "";
if (response.StatusCode == HttpStatusCode.OK)
{
JsonDeserializer deserial = new JsonDeserializer();
OssBucketsObjectsResponse bucketsObjectsResponse = deserial.Deserialize<OssBucketsObjectsResponse>(response);
id = bucketsObjectsResponse.objects[0].id;
}
return id; // "urn:xxx"
}