有没有人有过在Xamarin上使用Amazon S3上传文件的经验?它应该很简单,但是我在使用它时遇到了麻烦。我正在尝试使用https://github.com/xamarin/amazon来上传这样的文件:
try
{
var client = new AmazonS3Client ("REDACTED", "REDACTED");
var transferUtility = new TransferUtility (client);
TransferUtilityUploadRequest request = new TransferUtilityUploadRequest()
.WithBucketName("bucketname")
.WithFilePath(image.LocalPath)
.WithKey("rodsTest")
.WithTimeout(5 * 60 * 1000);
transferUtility.Upload(request);
} catch (Exception ex){
Console.WriteLine (ex.ToString ());
}
但我遇到了这个异常:
系统对象处理异常:该对象在释放后被使用。在System.Net.WebConnection.BeginWrite(系统.Net.HttpWebRequest请求,系统.Byte[]缓冲区,Int 32偏移量,Int 32大小,系统.AsyncCallback cb,系统.对象状态)[0x 0001 f]位于/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:1033在System.Net.WebConnectionStream.BeginWrite(系统.Byte[]缓冲区,Int 32偏移量,Int 32大小,系统.AsyncCallback cb,系统.对象状态)[0x 0026 c]位于/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:541
Github repo已经一年没有更新了,所以可能是坏了吧?我想做的就是PUT和DELETE文件,所以我的下一步是用RestSharp来使用REST API,而不是使用 Package 器,但肯定是其他人已经做过了,有人能解释一下吗?
1条答案
按热度按时间ql3eal8s1#
查看:使用xamarin c#上传亚马逊s3文件