/// <summary> /// 上传文件 /// </summary> /// <param name="bucket"></param> /// <param name="key"></param> /// <param name="file"></param> /// <returns></returns> public async Task <OssResult <PutObjectResult> > PutObjectAsync(BucketInfo bucket, string key, RequestContent file, IDictionary <string, string> extraHeaders = null) { if (key.StartsWith("/")) { throw new ArgumentException($"{nameof(key)} can not start with '/'"); } var cmd = new PutObjectCommand(_requestContext, bucket, key, file, extraHeaders); var result = await cmd.ExecuteAsync(_client); if (!result.IsSuccess) { _logger.LogError($"Failed in OssClient.{nameof(PutObjectAsync)}(). \nBucket: {bucket.BucketName}\nPath: {key}"); } return(result); }
/// <summary> /// 上传文件 /// </summary> /// <param name="bucket"></param> /// <param name="key"></param> /// <param name="file"></param> /// <returns></returns> public async Task <OssResult <PutObjectResult> > PutObjectAsync(BucketInfo bucket, string key, RequestContent file) { var cmd = new PutObjectCommand(_requestContext, bucket, key, file, null); return(await cmd.ExecuteAsync()); }