C# Xamarin Amazon S3上传
有没有人有在Xamarin上使用AmazonS3文件上传的经验?它应该很简单,但我很难让它工作。我正在尝试使用以下方式上载文件:C# Xamarin Amazon S3上传,c#,.net,amazon-s3,mono,xamarin,C#,.net,Amazon S3,Mono,Xamarin,有没有人有在Xamarin上使用AmazonS3文件上传的经验?它应该很简单,但我很难让它工作。我正在尝试使用以下方式上载文件: try { var client = new AmazonS3Client ("REDACTED", "REDACTED"); var transferUtility = new TransferUtility (client); TransferUtilityUploadRequest request = new TransferUtili
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.ObjectDisposedException:对象在被释放后被使用。在System.Net.WebConnection.BeginWrite(System.Net.HttpWebRequest请求、System.Byte[]缓冲区、Int32偏移量、Int32大小、System.AsyncCallback cb、System.Object状态)[0x0001f]in/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnection.cs:1033 at System.Net.WebConnectionStream.BeginWrite(System.Byte[]缓冲区,Int32偏移量,Int32大小,System.AsyncCallback cb,System.Object状态)[0x0026c]位于/Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebConnectionStream.cs:541
github回购协议已经一年没有更新了,所以可能只是坏了?我所要做的就是放置和删除文件,所以我的下一步就是用RestSharp点击RESTAPI,而不是使用包装器,但肯定这是其他人做过的事情,有人能解释一下吗?检查:使用xamarin c上传amazon s3文件#
AmazonS3Config config = new AmazonS3Config();
config.ServiceURL = serviceUrl;//amazon s3 URL
config.UseHttp = true;
config.RegionEndpoint =Amazon.RegionEndpoint.APNortheast1;//your region
AmazonS3Client client = new AmazonS3Client(accessKey,
secretAccessKey, config);
TransferUtility transferUtility = new TransferUtility(client);
TransferUtilityUploadRequest request = new TransferUtilityUploadRequest();
request.BucketName = s3Bucket;
request.FilePath = filePath;//local file path
//Test that the path is correct
UIImage image = UIImage.FromFile(filePath);
System.Threading.CancellationToken canellationToken = new System.Threading.CancellationToken();
await transferUtility.UploadAsync(request, canellationToken);