[ad_1]
File.WriteAllBytes("D:/" + model.FileBase.FileName, model.FileBase.Data); byte[] bytes = Convert.FromBase64String(model.file); using (var inputStream = new MemoryStream(model.FileBase.Data)) { inputStream.Position = 0; await s3Client.PutObjectAsync(new PutObjectRequest { InputStream = inputStream, ContentType = MimeMapping.GetMimeMapping(model.fileName + model.fileExtension), BucketName = model.bucketName, Key = model.fileName, FilePath = model.destination, CannedACL = S3CannedACL.BucketOwnerFullControl }); }
ما حاولت:
قادر على حفظ الملف على محرك الأقراص D ولكن أثناء النشر إلى مجموعة s3 يظهر خطأ
Please specify one of either an InputStream or a FilePath to be PUT as an S3 object.'
at Amazon.S3.Internal.AmazonS3PreMarshallHandler.ProcessPreRequestHandlers(IExecutionContext executionContext) at Amazon.S3.Internal.AmazonS3PreMarshallHandler.InvokeAsync[T](IExecutionContext executionContext) at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at WebApi.Controllers.S3BucketController.<Post>d__2.MoveNext() in C:\Users\Satya\Downloads\WebApi\Controllers\S3BucketController.cs:line 62
الحل 1
رسالة الخطأ مربكة بعض الشيء، ولكن بمجرد رؤيتها، تصبح المشكلة واضحة:
يقتبس:رجاء حدد واحد منهما InputStream أو FilePath ليتم وضعه ككائن S3.
الخطأ يخبرك أنك حددت كلاهما ان InputStream
و أ FilePath
، وهو غير معتمد.
مسح ال FilePath
الملكية من الخاص بك PutObjectRequest
هدف.
[ad_2]
コメント