Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin Amazon S3上传_C#_.net_Amazon S3_Mono_Xamarin - Fatal编程技术网

C# Xamarin Amazon S3上传

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

有没有人有在Xamarin上使用AmazonS3文件上传的经验?它应该很简单,但我很难让它工作。我正在尝试使用以下方式上载文件:

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);