在 .NET Core 中调用腾讯云对象存储(COS)Web API,对应的主要 C# 代码如下:
var path = HttpUtility.UrlPathEncode(remotePath.TrimStart('/')); var url = $"{BASE_ADDRESS}{_cosClientOptions.AppId}/{bucketName}/{path}"; var signature = GenerateSignature(bucketName, remotePath); var boundary = "---------------" + DateTime.Now.Ticks.ToString("x"); var fileName = Path.GetFileName(remotePath); var request = new HttpRequestMessage(HttpMethod.Post, url); request.Headers.Authorization = new AuthenticationHeaderValue("Authorization", signature); var data = new MultipartFormDataContent(boundary); data.Add(new ByteArrayContent(Encoding.UTF8.GetBytes("upload")), "op"); data.Add(new StreamContent(uploadStream), "fileContent", fileName); request.Content = data; var response = await _httpClient.SendAsync(request);
调用时总是报下面的错误:
{"code":-5964,"message":"ERROR_CGI_PARAM_NO_SUCH_OP","request_id":"NWEwMmMwOTVfYzdhMDY4NjRfMjM3OWNfMjQ1OTNj"}
请问如何解决?