Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

需要所有上传与下载请求都支持Async异步方法 #101

Open
FatTigerWang opened this issue Mar 20, 2020 · 5 comments
Open

需要所有上传与下载请求都支持Async异步方法 #101

FatTigerWang opened this issue Mar 20, 2020 · 5 comments

Comments

@FatTigerWang
Copy link

我们正在ASP.NET Core上使用Aliyun OSS SDK,但是发现没有异步上传的方法,能否提供?

@FatTigerWang
Copy link
Author

看了你们是基于HttpWebRequest的.....

@liguobao
Copy link

liguobao commented Jun 1, 2020

同样需要。

@LeaFrock
Copy link

LeaFrock commented Sep 4, 2020

三年前就有人提出支持async/await、返回Task的API了……
阿里维护的.NET项目,也只能这样了。
时间越长,更是积重难返,又没效益。

@liguobao
Copy link

现在正在使用的异步方法。

 /// <summary>
        /// 获取OSS文件内容
        /// </summary>
        public async Task<Stream> GetFileContentAsync(string ossKey)
        {
            var tcs = new TaskCompletionSource<OssObject>();
            _ossClient.BeginGetObject(_config.AliyunOSSFileContentBucket,
                ossKey,
                asyncResult =>
                {
                    var result = _ossClient.EndGetObject(asyncResult);
                    tcs.SetResult(result);
                },
                null);
            var result = await tcs.Task;
            if (result.HttpStatusCode == HttpStatusCode.NotFound)
            {
                return default(Stream);
            }

            return result.ResponseStream;
        }

这就很蛋疼了////

@LeaFrock
Copy link

更新:新版OSS SDK可以关注此仓库。底层使用的HttpClient,有纯异步的API。Nuget搜索AlibabaCloud.SDK.Oss20190517即可。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants