我已通过创建存储位置API按3脚标记,accessToken
和bucketKey
生成objectName
,如所示。
我想将文件上传到存储位置。我的请求返回'OK 200'状态,但它不会将文件上传到A360,因为我需要。 哪里出错了?如何使用3-legged Token正确地将文件上传到用户的存储位置?
[HttpGet]
public JObject UploadFile(string accessToken,string bucketKey,string objectName,string filePath)
{
var url = String.Format("https://developer.api.autodesk.com/oss/v2/buckets/{0}/objects/{1}", bucketKey, objectName);
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var response = client.PutAsync(url, new StreamContent(System.IO.File.OpenRead(filePath))).Result.EnsureSuccessStatusCode();
System.Diagnostics.Debug.WriteLine(response);
}
}
Request必须返回带有创建文件参数的JSON,但返回:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Authorization, Accept-Encoding, Range, Content-Type
Access-Control-Allow-Methods: GET
Access-Control-Allow-Origin: *
Connection: keep-alive
Date: Wed, 11 Jan 2017 15:36:21 GMT
Server: Apigee
Server: Router
Content-Length: 440
Content-Type: application/json; charset=utf-8
}