aliyun / aliyun-oss-csharp-sdk Goto Github PK
View Code? Open in Web Editor NEWAliyun OSS SDK for C#
License: MIT License
Aliyun OSS SDK for C#
License: MIT License
在上传文件到OSS时,若文件的后缀名是大写的,则匹配ContentType是为二进制流了,这个需要不区分大小写
HttpUtils.cs的第118行代码:
原代码为:fileType = fileType.Trim().TrimStart(new char[1] { '.' })
修改为:fileType = fileType.Trim().TrimStart(new char[1] { '.' }).ToLower();
即可实现上述的需求
发生了未经处理的异常,已终止进程。
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呢?
四月9号以来,就没动静了。。
能给个回复么??
还是说.net core那个分支也可以上生产环境了?
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()
完全没有头绪
能不能使用Async/Await,别用那个Begin..../End.........了?
Always prompt does not have permission to access the folder in GetObject code paragraph.
能写个在MVC中应用的例子嘛?
或WEBAPI的例子
再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)
原因也非常简单,你们上面已经读取过一次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)
……
您好,
因为直接在unity客户端使用keyid,secretid操作文件的话,权限太大了,请问Unity分支是否支持使用临时token上传文件,因为我看教程没这方面的example。
有支持.net core的计划么
使用异步上传文件时,如果网络连接失败,或者在连接成功后写入数据超时,将导致进程崩溃
错误信息:
发生了未经处理的异常,已终止进程。
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()
建议netcore2.0改为net standard 2.0
.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版本的解决方案。希望有人能解决下。
Project Type: .NET Core (2.2)
Referenced Nuget package: Aliyun.OSS.SDK v2.9.0
Got exception when endpoint is invalid.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
创建存储空间失败. 原因: Object reference not set to an instance of an object
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);
}
断点续传中checkpointDir应该以什么样的格式来保存使用
系统环境 windows 7 旗舰版 Visual Studio 2010 旗舰版
在.Net Framework 4.0 Mvc 3.0 web 程序中引用2.9.0版本
https://www.nuget.org/packages/Aliyun.OSS.SDK
Install-Package Aliyun.OSS.SDK -Version 2.9.0
引用后 using Aliyun.OSS;未能找到命名空间
ResumableContext文件路径问题:
未能找到路径“D:\Debug;bW90aWMxMA==_dGVzdC\lvbHlg4\lrabotYTmlpkt5YiY5qC56L+eX2ZfNTV5LTIzNC5yYXI=”的一部分。
gif资源的ContentType被识别为application/octet-stream了
以后的版本是否支持批量文件上传和批量上传的进度条?急需这个功能
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
你好,什么时候可以在 nuget.org上更新 2.9.1版本呢
查了一下,还是有部分用户希望OSS有解压的能力
我想连续删除多个文件.
要删除的数量大概有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"
请问这个怎么解决.
Java SDK https://help.aliyun.com/document_detail/47505.html?spm=a2c4g.11186623.2.15.4301cb462mqZMy#section-rqc-yfd-lfb
有ProcessObjectRequest对象,.NET SDK没有?该怎么做?谢谢
现在Nuget最新版本是2.9.0,存在非200则500的错误,2.9.1能不能尽快发布到Nuget
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
这个是连接不上吗,还是不支持,还是怎么样的。求解释。
一直就是Failed with error info: An exception was thrown by the type initializer for Aliyun.OSS.Util.HttpUtils
写一个呗?要不然光有上传,没下载就很心碎了,毕竟全文件获取也是有机会用的。
按照文档中的描述,在一个私有的bucket中拼装出一个自定义的带style的Resource(object@!60w60h)
得到的url总是报The request signature we calculated does not match the signature you provided. Check your key and signing method.错误。
不知道有没有人碰到过这个问题。
nuget一直都是2.8版,而2.9版才支持.net core2。。。
我发现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 ...
}
希望官方尽快实现这个接口。
调用 GetObjectMetadata 方法时发现有5G最大限制,但是我的文件超过了8G。
不知设置这个限制是基于何种考虑?
ObjectMetadata.cs => ContentLength => set
使用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分钟。这个异常可能是由什么原因导致的?有什么办法解决么?
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下会报这个错
异步上传能不能改成Task啊
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);
}
}
}
`
什么时候能出.Net Core的demo?目前我们项目是.Net Core
如题,我在C#使用了类似:
metadata.UserMetadata.Add("share_in", "abcd");
的代码,出现错误:The request signature we calculated does not match the signature you provided. Check your key and signing method.
不要就没事。
你好,请问Unity版本的SDK什么时候可用?急急急
环境: .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换成文件路径则可以成功上传
请问有什么解决办法吗
异常: “An exception was thrown by the type initializer for Aliyun.OSS.Util.HttpUtils”
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.