StorageClient UploadObjectAsync periodically throws exception TaskwasCancelled

有些话、适合烂在心里 提交于 2020-01-06 07:06:29

问题


I am using Google Storage Client to upload the File.

However, it never uploads. Suddenly this throwing exception always-TaskCanceledException. Even the CancellationTokenSource never cancelled.

IProgress<IUploadProgress> UploadProgress = new Progress<IUploadProgress>(OnUploadProgress);

using (FileStream fileStream = File.OpenRead(localpath))
{

    if (null != await StorageClient.UploadObjectAsync(bucketname, objectname, null, fileStream, null, CancellationTokenSource.Token, UploadProgress))
    { 
        result = true;
    }
}

private void OnUploadProgress(IUploadProgress googleProgress)
{
    case Google.Apis.Upload.UploadStatus.Failed:
    {
        //always come inside this...
        googleProgress.Exception is TaskCanceledException
    }

    break;
}

来源:https://stackoverflow.com/questions/55831013/storageclient-uploadobjectasync-periodically-throws-exception-taskwascancelled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!