开发者社区> 问答> 正文

OSS在.net core 2.1上传报错The stream was already consumedIt cannot be read again.

public string UploadFile(string key, string localFilename)
    {
      string resultMsg = string.Empty;
      try
      {
OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
        client.PutObject(Name, key, localFilename);
      }
      catch (OssException ex)
      {
        resultMsg = string.Format("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
            ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
      }
      catch (Exception ex)
      {
        resultMsg = "Failed with error info: " + ex.Message;
      }
      return resultMsg;
    }

string key = "test-file-"+DateTime.Now.ToString("yyyyMMddHHmmss");
string vResult = UploadFile(key, @"D:\Files\test.png");

代码见上,然后报错
The stream was already consumed. It cannot be read again.
我这是哪里写的有问题吗?

展开
收起
jitdd 2018-10-26 19:14:11 4971 0
1 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
OSS运维进阶实战手册 立即下载
《OSS运维基础实战手册》 立即下载
OSS运维基础实战手册 立即下载