我正在尝试从我的Xamarin PCL项目将上传的图像发送到Amazon S3容器,以便android和iOS使用此代码工作,这是我的代码:
private async void PickPhoto()
{
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await App.Current.MainPage.DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
return;
}
var file = await CrossMedia.Current.PickPhotoAsync();
if (file == null)
return;
this.OrgLogo = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
try
{
var credentials = new BasicAWSCredentials("xxxxxx", "xxxxxxxx");
var client = new AmazonS3Client(credentials, RegionEndpoint.USEast1);
var transferUtility = new TransferUtility(client);
var filePath = file.Path;
await transferUtility.UploadAsync(
filePath,
"xxx"
);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
但是得到如下的异常:
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: Not implemented in reference assembly.
at PCLCrypto.WinRTCrypto.get_HashAlgorithmProvider () [0x00000] in :0
at Amazon.Runtime.Internal.Util.HashingWrapper.Init (System.String algorithmName) [0x00016] in D:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util_pcl-sl\HashingWrapper.pcl.cs:42
at Amazon.Runtime.Internal.Util.HashingWrapper..ctor (System.String algorithmName) [0x00019] in D:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\HashingWrapper.cs:31
at Amazon.Runtime.Internal.Util.HashingWrapperMD5..ctor () [0x00000] in D:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util_pcl-sl\HashingWrapper.pcl.cs:116
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3540/1cf254db/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
有人可以帮助我做错了吗?
答案 0 :(得分:0)
使用完全相同的插件我遇到了完全相同的问题。它似乎与PCLCrytpo库的Windows版本有关。由于我不关心Windows版本,我做了以下内容:
这似乎解决了我的问题