Giter Site home page Giter Site logo

aliyun-oss-csharp-sdk's Issues

匹配ContentType时要大小写不敏感

在上传文件到OSS时,若文件的后缀名是大写的,则匹配ContentType是为二进制流了,这个需要不区分大小写
HttpUtils.cs的第118行代码:
原代码为:fileType = fileType.Trim().TrimStart(new char[1] { '.' })
修改为:fileType = fileType.Trim().TrimStart(new char[1] { '.' }).ToLower();

即可实现上述的需求

2.5.1 及之前的版本都会在上传网络超时时导致 IIS W3P进程崩溃,后续版本未测试

发生了未经处理的异常,已终止进程。

Application ID: /LM/W3SVC/11/ROOT

Process ID: 10568

Exception: System.Net.WebException

Message: 请求被中止: 请求已被取消。

StackTrace: 在 System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
在 System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
在 System.Net.ConnectStream.Dispose(Boolean disposing)
在 System.IO.Stream.Close()
在 Aliyun.OSS.Common.Communication.ServiceClientImpl.<>c__DisplayClass6.b__4(IAsyncResult ar)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.HttpWebRequest.InvokeGetRequestStreamCallback()
在 System.Net.HttpWebRequest.EndWriteHeaders_Part2()
在 System.Net.HttpWebRequest.SetRequestContinue(CoreResponseData continueResponse)
在 System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

InnerException: System.IO.IOException

Message: 在写入所有字节之前不能关闭流。

StackTrace: 在 System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)

.net core 分支几时合到master呢?

.net core 分支几时合到master呢?
四月9号以来,就没动静了。。
能给个回复么??
还是说.net core那个分支也可以上生产环境了?

Aliyun.OSS.OssClient.DoesObjectExist 报 NullReferenceException 异常,为什么?

Aliyun.OSS.dll 版本:2.5.1.0 【升级 aliyun_oss_dotnet_sdk_2_8_0 后一样】
OSVersion:Microsoft Windows NT 6.2.9200.0 NetFrameworkVersion:4.0.30319.42000

System.NullReferenceException: 未将对象引用设置到对象的实例。
在 Aliyun.OSS.OssClient.DoesObjectExist(String bucketName, String key)
在 xxxx.UploadAliyunOSSImage()

完全没有头绪

dotnet core 2.1报错

再dotnet core 2.0 下运行正常
dotnet core 2.1报错
错误信息如下:

The stream was already consumed. It cannot be read again.

   at System.Net.Http.HttpConnection.HttpConnectionResponseContent.ConsumeStream()
   at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
   at System.Net.Http.HttpContent.CopyToAsyncCore(ValueTask copyTask)

你们的代码到底有没有经过测试?任何请求只要响应代码不是200 OK就会直接在这个位置异常。

_response.Content.CopyToAsync(_stream).Wait();

原因也非常简单,你们上面已经读取过一次Content Stream了,发现状态码不是200 OK的时候又读取一次Content Stream,就会造成这个异常:

System.AggregateException: One or more errors occurred. (The stream was already consumed. It cannot be read again.) ---> System.InvalidOperationException: The stream was already consumed. It cannot be read again.
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.ConsumeStream()
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.CopyToAsyncCore(ValueTask copyTask)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Aliyun.OSS.Common.Communication.ServiceClientNewImpl.ResponseImpl..ctor(HttpResponseMessage httpWebResponse)
at Aliyun.OSS.Common.Communication.ServiceClientNewImpl.SendCore(ServiceRequest request, ExecutionContext context)
at Aliyun.OSS.Common.Communication.ServiceClient.Send(ServiceRequest request, ExecutionContext context)
at Aliyun.OSS.Common.Communication.RetryableServiceClient.SendImpl(ServiceRequest request, ExecutionContext context, Int32 retryTimes)
at Aliyun.OSS.Commands.OssCommand.Execute()
at Aliyun.OSS.OssClient.ListObjects(ListObjectsRequest listObjectsRequest)
……

使用异步上传文件时,如果网络连接失败,或者在连接成功后写入数据超时,将导致进程崩溃

使用异步上传文件时,如果网络连接失败,或者在连接成功后写入数据超时,将导致进程崩溃

错误信息:

发生了未经处理的异常,已终止进程。

Application ID: /LM/W3SVC/5/ROOT

Process ID: 2396

Exception: System.Net.WebException

Message: 无法连接到远程服务器

StackTrace:    在 System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   在 System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   在 Aliyun.OSS.Common.Communication.ServiceClientImpl.<>c__DisplayClass6.<SetRequestContent>b__4(IAsyncResult ar)
   在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
   在 System.Net.HttpWebRequest.SetResponse(Exception E)
   在 System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
   在 System.Net.Connection.CompleteConnectionWrapper(Object request, Object state)
   在 System.Net.PooledStream.ConnectionCallback(Object owningObject, Exception e, Socket socket, IPAddress address)
   在 System.Net.ServicePoint.ConnectSocketCallback(IAsyncResult asyncResult)
   在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
   在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

InnerException: System.Net.Sockets.SocketException

Message: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

StackTrace:    在 System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
发生了未经处理的异常,已终止进程。

Application ID: /LM/W3SVC/5/ROOT

Process ID: 4756

Exception: System.IO.IOException

Message: 无法从传输连接中读取数据: 连接已关闭。

StackTrace:    在 System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
   在 System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   在 Aliyun.OSS.Util.IoUtils.WriteTo(Stream orignStream, Stream destStream, Int64 totalSize)
   在 Aliyun.OSS.Common.Communication.ServiceClientImpl.<>c__DisplayClass6.<SetRequestContent>b__4(IAsyncResult ar)
   在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
   在 System.Net.HttpWebRequest.InvokeGetRequestStreamCallback()
   在 System.Net.HttpWebRequest.EndWriteHeaders_Part2()
   在 System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   在 System.Threading.ThreadPoolWorkQueue.Dispatch()

.net core版本SendCore()方法抛出 “无法发送具有此谓词类型的内容正文”意外!

.net core版本SendCore()方法抛出 “无法发送具有此谓词类型的内容正文”意外!但.net版本没有这个问题。

core版本抛出意外的地方:

protected override ServiceResponse SendCore(ServiceRequest request, ExecutionContext context)
{
var req = new HttpRequestMessage(Convert(request.Method), request.BuildRequestUri());
this.SetRequestContent(req, request);
this.SetHeaders(req, request);
HttpClient client = GetClient();
HttpResponseMessage resp = client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead).Result;
return new ResponseImpl(resp);
}

.net版本是这样实现的:

protected override ServiceResponse SendCore(ServiceRequest serviceRequest, ExecutionContext context)
{
var request = HttpFactory.CreateWebRequest(serviceRequest, Configuration);
SetRequestContent(request, serviceRequest, Configuration);
try
{
var response = request.GetResponse() as HttpWebResponse;
return new ResponseImpl(response);
}
catch (WebException ex)
{
return HandleException(ex);
}
}

高度怀疑.net core的实现方法有BUG。
这个问题已经导致我们无法使用.net core版本的解决方案。希望有人能解决下。

Unity SDK 空引用

创建存储空间失败. 原因: Object reference not set to an instance of an object

BeginPutObject函数的文件流释放造成异步请求报错

  public IAsyncResult BeginPutObject(string bucketName, string key, string fileToUpload, ObjectMetadata metadata,
            AsyncCallback callback, object state)
        {
            if (!File.Exists(fileToUpload) || Directory.Exists(fileToUpload))
                throw new ArgumentException(String.Format("Invalid file path {0}.", fileToUpload));

            metadata = metadata ?? new ObjectMetadata();
            SetContentTypeIfNull(key, fileToUpload, ref metadata);

            IAsyncResult result;
            //TODO 这里释放了content导致ServiceClientImpl报错
            using (Stream content = File.OpenRead(fileToUpload))
            {
                result = BeginPutObject(bucketName, key, content, metadata, callback, state);
            }
            return result;
        }

ServiceClientImpl报错位置

  if (async)
            {
                webRequest.BeginGetRequestStream(
                    (ar) =>
                    {
                        using (var requestStream = webRequest.EndGetRequestStream(ar))
                        {
                            //TODO data已被释放
                            IoUtils.WriteTo(data, requestStream, webRequest.ContentLength);
                        }
                        asyncCallback();
                    }, null);
            }

ResumableUpload接口问题

ResumableContext文件路径问题:
未能找到路径“D:\Debug;bW90aWMxMA==_dGVzdC\lvbHlg4\lrabotYTmlpkt5YiY5qC56L+eX2ZfNTV5LTIzNC5yYXI=”的一部分。

在服务端签名后如何使用sdk上传文件

    static string accessKeyId = Config.AccessKeyId;
    static string accessKeySecret = Config.AccessKeySecret;
    static string endpoint = Config.Endpoint;
    static OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);

使用OssClient必须把accessKeyId 和accessKeySecret写在客户端的代码里,这样不太安全,如何通过服务端生成上传文件的postPolicy

删除1000个文件就报错

我想连续删除多个文件.
要删除的数量大概有100万个左右.
因此调用了DeleteObjects这个接口

while (true)
{
var listResult = _client.ListObjects(txt_selbucketname.Text);

                var coll = listResult.ObjectSummaries;
                if (coll==null||coll.Count()==0)
                {
                    break;
                }
                foreach (var summary in coll)
                {
                    keys.Add(summary.Key);
                }

                var request = new DeleteObjectsRequest(txt_selbucketname.Text, keys, false);
                DeleteObjectsResult dresult = _client.DeleteObjects(request);
                

                string str = dresult.HttpStatusCode.ToString();
                textBox4.AppendText(str + " " + Environment.NewLine + " ");
            }

在一个while中 进行删除工作(因为 每次最多只可以查找100个文件.)
结果在删除1000后爆出异常:
"Count of objects to be deleted exceeds upper limit"

请问这个怎么解决.

亲,这个可以在unity里使用吗?

public void Initialize(string endpoint, string accessKeyId, string accessKeySecret) {
    try {
        client = new OssClient(endpoint, accessKeyId, accessKeySecret);
        client.ListBuckets();
    } catch (System.Exception e) {
        Debug.LogErrorFormat("Connect aliyun failed, Reason:{0}", e.Message);
    }
}

这段代码执行的时候,报的错误是:Connect aliyun failed, Reason:Object reference not set to an instance of an object
这个是连接不上吗,还是不支持,还是怎么样的。求解释。

私有bucket在URL中包含签名问题

https://help.aliyun.com/document_detail/oss/api-reference/access-control/signature-url.html?spm=5176.docoss/oss-img-guide/access/signature.2.9.e3B1jt

按照文档中的描述,在一个私有的bucket中拼装出一个自定义的带style的Resource(object@!60w60h)
得到的url总是报The request signature we calculated does not match the signature you provided. Check your key and signing method.错误。

不知道有没有人碰到过这个问题。

请添加RestoreObject命令的支持!

我发现C# SDK里面并没有RestoreObject的命令支持。Java SDK里面已经对该功能有所支持,并且能成功使用。
我也尝试过自己去参照其它指令去实现,发现返回了405 - Method Not Allowed的错误。下面是我的实现方式:

添加RestoreObjectCommand.cs

using System;
using System.Collections.Generic;
using Aliyun.OSS.Common.Communication;
using Aliyun.OSS.Util;

namespace Aliyun.OSS.Commands
{
    internal class RestoreObjectCommand : OssCommand
    {
        public RestoreObjectRequest Request { get; private set; }

        protected override string Key { get { return Request.Key; } }
        protected override string Bucket { get { return Request.BucketName; } }
        protected override HttpMethod Method { get { return HttpMethod.Post; } }

        private RestoreObjectCommand(IServiceClient client, Uri endpoint, ExecutionContext context, RestoreObjectRequest request) : base(client, endpoint, context)
        {
            Request = request;
        }

        public static RestoreObjectCommand Create(IServiceClient client, Uri endpoint,
                                                 ExecutionContext context, RestoreObjectRequest request)
        {
            return new RestoreObjectCommand(client, endpoint, context, request);
        }

        protected override IDictionary<string, string> Parameters
        {
            get
            {
                var parameters = base.Parameters;
                parameters[RequestParameters.SUBRESOURCE_RESTORE] = null;
                return parameters;
            }
        }
    }
}

IOss.cs加入RestoreObject接口

public interface IOss
{
// .... ignore multiple lines ... 
        /// <summary>
        /// 解冻文件<see cref="RestoreObjectResult" />。
        /// </summary>
        /// <param name="bucketName"><see cref="Bucket" />的名称。</param>
        /// <param name="key"><see cref="OssObject.Key" />。</param>
        /// <returns></returns>
        RestoreObjectResult RestoreObject(string bucketName, string key);
// .... ignore multiple lines ... 
}

OssClient.cs里加入RestoreObject接口的实现

public class OssClient : IOss
 {
// .... ignore multiple lines ... 

        public RestoreObjectResult RestoreObject(string bucketName, string key)
        {
            var cmd = RestoreObjectCommand.Create(_serviceClient, _endpoint,
                CreateContext(HttpMethod.Post, bucketName, key),
                new RestoreObjectRequest(bucketName, key));

            var response = cmd.Execute();

            var result = new RestoreObjectResult((int)response.StatusCode);

            return result;
        }
// .... ignore multiple lines ... 
}

希望官方尽快实现这个接口。

content length not allow to exceed 5GB

调用 GetObjectMetadata 方法时发现有5G最大限制,但是我的文件超过了8G。

不知设置这个限制是基于何种考虑?

ObjectMetadata.cs => ContentLength => set

未能解析此远程名称: 'xxxxxxxx.oss-cn-shanghai.aliyuncs.com'

使用SDK的AppendObject上传文件(一直不停的上传)时,有时会出现下面这个异常:
System.Net.WebException: 未能解析此远程名称: 'vdodev-smpv.oss-cn-shanghai.aliyuncs.com'
在 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
在 System.Net.HttpWebRequest.GetRequestStream()
在 Aliyun.OSS.Common.Communication.ServiceClientImpl.SetRequestContent(HttpWebRequest webRequest, ServiceRequest serviceRequest, Boolean async, OssAction asyncCallback)
在 Aliyun.OSS.Common.Communication.ServiceClientImpl.SendCore(ServiceRequest serviceRequest, ExecutionContext context)
在 Aliyun.OSS.Common.Communication.ServiceClient.Send(ServiceRequest request, ExecutionContext context)
在 Aliyun.OSS.Common.Communication.RetryableServiceClient.SendImpl(ServiceRequest request, ExecutionContext context, Int32 retryTimes)
在 Aliyun.OSS.Common.Communication.RetryableServiceClient.Send(ServiceRequest request, ExecutionContext context)
在 Aliyun.OSS.Commands.OssCommand.Execute()
在 Aliyun.OSS.OssClient.AppendObject(AppendObjectRequest request)
在 NVR2OSS.ObjectUploader.AppendObjectSync(Stream stream, String key, Boolean resetPos)

这个异常出现的持续时间有长有短。短的时候出现一两次就可以正常上传文件了,长的一次持续了23分钟。这个异常可能是由什么原因导致的?有什么办法解决么?

在mac unity上GetObject报错

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
at System.Net.WebConnection.BeginRead (System.Net.HttpWebRequest request, System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback cb, System.Object state) [0x0002b] in <3845a180c26b4889bc2d47593a665814>:0
at System.Net.WebConnectionStream.BeginRead (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.AsyncCallback cb, System.Object state) [0x0017d] in <3845a180c26b4889bc2d47593a665814>:0
at System.Net.WebConnectionStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x00007] in <3845a180c26b4889bc2d47593a665814>:0
at Aliyun.OSS.Common.Internal.WrapperStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00000]

使用的方法为

try
{
// 下载文件到流。OssObject 包含了文件的各种信息,如文件所在的存储空间、文件名、元信息以及一个输入流。
var obj = client.GetObject(bucketName, objectName);
using (var requestStream = obj.Content)
{
byte[] buf = new byte[1024];
var fs = File.Open(downloadFilename, FileMode.OpenOrCreate);
var len = 0;
// 通过输入流将文件的内容读取到文件或者内存中。
while ((len = requestStream.Read(buf, 0, 1024)) != 0)
{
fs.Write(buf, 0, len);
}
fs.Close();
}
Console.WriteLine("Get object succeeded");
}
catch (Exception ex)
{
Console.WriteLine("Get object failed. {0}", ex.Message);
}

在Windows下,Unity里使用没有任何问题,在Mac下会报这个错

Unity 5.3.4f1 Editor下使用正常 打包发布apk后报错

Common/Authentication/Authentication.cs文件下
` protected override string ComputeSignatureCore(string key, string data)
{
Debug.Assert(!string.IsNullOrEmpty(data));

        using (var algorithm = KeyedHashAlgorithm.Create(SignatureMethod.ToUpperInvariant()))
        {
            algorithm.Key = Encoding.GetBytes(key.ToCharArray());
            return Convert.ToBase64String(
                algorithm.ComputeHash(Encoding.GetBytes(data.ToCharArray())));
        }
    }`

Encoding.GetBytes 出现异常 有什么解决办法吗?

获取图片缩略图失败

使用2.9.1时:
在获取 image/xxxx_middle 时,报异常: Expected hash not equal to calculated hash

恢复到 2.5.1时正常。。。

相关代码
`

strKey = string.Format("{0}_middle", this.Key);

AliyunOSSDownloadRequest adrRequest = new AliyunOSSDownloadRequest();
adrRequest.LogId = strDownloadAliyunOSSBreviaryImageId;
adrRequest.Client = AliyunOSSHandle.DownloadClient;
adrRequest.BucketName = AliyunOSSHandle.BucketName;
adrRequest.Key = strKey;
adrRequest.Path = strBreviaryFile;
adrRequest.PartSize = 100 * 1024;
AliyunOSSHandle.Download(adrRequest);
`

`
public static void Download(AliyunOSSDownloadRequest mudrRequest)
{
OssObject ooObject = mudrRequest.Client.GetObject(mudrRequest.BucketName, mudrRequest.Key);
using (Stream requestStream = ooObject.Content)
{
long lnLength = ooObject.Metadata.ContentLength;
long lnPosition = 0L;
byte[] buf = new byte[mudrRequest.PartSize];
long lnWatchCount = 0L;
System.Diagnostics.Stopwatch swWatch = new System.Diagnostics.Stopwatch();
swWatch.Start();
using (FileStream fs = File.Open(mudrRequest.Path, FileMode.OpenOrCreate))
{
var len = 0;
while ((len = requestStream.Read(buf, 0, buf.Length)) != 0)
{
fs.Write(buf, 0, len);
if (mudrRequest.ProgressChanged)
{
lnPosition += len;
lnWatchCount += len;

                AliyunOSSDownloadProgressChanged adpcChanged = new AliyunOSSDownloadProgressChanged();
                adpcChanged.Progress = 100.0D * lnPosition / lnLength;
                adpcChanged.PartIndexs = new SafeList<int>();
                long lnTime = swWatch.ElapsedMilliseconds;
                if (lnTime >= 500)
                {
                    swWatch.Reset();
                    swWatch.Start();
                    adpcChanged.SpeekValid = true;
                    adpcChanged.Speek = lnWatchCount / lnTime * 1000;
                    if (adpcChanged.Speek > 0)
                    {
                        adpcChanged.RemainingTime = (lnLength - lnPosition) / adpcChanged.Speek;
                    }
                    lnWatchCount = 0L;
                }
                mudrRequest.OnDownloadProgressChanged(adpcChanged);
            }
        }
        swWatch.Stop();
    }
}

if (!string.IsNullOrEmpty(mudrRequest.MD5))
{
    // MD5比较
}

if (mudrRequest.ProgressChanged)
{
    AliyunOSSDownloadProgressChanged mudcEndChanged = new AliyunOSSDownloadProgressChanged();
    mudcEndChanged.Progress = 100.0D;
    mudcEndChanged.PartIndexs = new SafeList<int>();
    mudrRequest.OnDownloadProgressChanged(mudcEndChanged);
}

}
`

`

public class AliyunOSSDownloadRequest
{

    private string mLogId;
    public string LogId
    {
        get { return mLogId; }
        set { mLogId = value; }
    }

    private OssClient mClient;
    public OssClient Client
    {
        get { return mClient; }
        set { mClient = value; }
    }

    private string mBucketName;
    public string BucketName
    {
        get { return mBucketName; }
        set { mBucketName = value; }
    }

    private string mKey;
    public string Key
    {
        get { return mKey; }
        set { mKey = value; }
    }

    private string mMD5;
    public string MD5
    {
        get { return mMD5; }
        set { mMD5 = value; }
    }

    private string mPath;
    public string Path
    {
        get { return mPath; }
        set { mPath = value; }
    }

    private long mLength;
    public long Length
    {
        get { return mLength; }
        set { mLength = value; }
    }

    private long mPartSize;
    public long PartSize
    {
        get { return mPartSize; }
        set { mPartSize = value; }
    }

    private SafeList<int> mPartIndexs = new SafeList<int>();
    public SafeList<int> PartIndexs
    {
        get { return mPartIndexs; }
        set { mPartIndexs = value; }
    }

    private SafeQueue<AliyunOSSDownloadPartStream> mPartStream = new SafeQueue<AliyunOSSDownloadPartStream>();
    public SafeQueue<AliyunOSSDownloadPartStream> PartStream
    {
        get { return mPartStream; }
        set { mPartStream = value; }
    }

    public event EventHandler<AliyunOSSDownloadProgressChanged> DownloadProgressChanged;
    public bool ProgressChanged
    {
        get { return this.DownloadProgressChanged != null; }
    }

    public void OnDownloadProgressChanged(AliyunOSSDownloadProgressChanged e)
    {
        if (this.DownloadProgressChanged != null)
        {
            this.DownloadProgressChanged(this, e);
        }
    }

}

`

IFormFile类型表单文件直接Save到MemoryStream实例后,PutObject失败

环境: .Net Core 环境下, Aliyun.OSS.dll 版本 2.8.0
具体描述:
var files = Request.Form.Files;
using (MemoryStream ms = new MemoryStream())
{
files[i].CopyTo(ms);
PutObjectResult result = _ossClient.PutObject(_ossSettings.Value.BucketName, key, ms);
}
如上代码会报 Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex 错误,
源码调试貌似 Aliyun.OSS.Common.Handlers.Crc64CheckHandler Handle方法中 var sdkCalculatedHash = BitConverter.ToUInt64(stream.CalculatedHash, 0); 此行代码报错, 因为 stream.CalculatedHash的值为 byte[], 不为空但没有值, 长度为0, 所以 Convert 失败, 导致上传不成功
如果将上诉代码的ms换成文件路径则可以成功上传
请问有什么解决办法吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.