1

我有以下代码在 s3 中上传文件。

AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client("AWSAccessKey", "AWSSecretKey");

String strS3KEY = "JSON_FILE_NAME";
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName("AWS_BUCKET");
request.WithKey(strS3KEY);
request.WithContentBody("Test");
request.CannedACL = S3CannedACL.PublicRead;
s3Client.PutObject(request);

这可以在本地系统中找到。当我在s3Client.PutObject(request);行中从部署服务器运行应用程序时 它给出了以下错误-

远程服务器返回错误:(407) 需要代理身份验证。

堆栈跟踪是 -

at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at Amazon.S3.AmazonS3Client.getRequestStreamCallback[T](IAsyncResult result)
at Amazon.S3.AmazonS3Client.endOperation[T](IAsyncResult result)
at Amazon.S3.AmazonS3Client.EndPutObject(IAsyncResult asyncResult)
at Amazon.S3.AmazonS3Client.PutObject(PutObjectRequest request)
at XMLandCloudConsole.Program.Main(String[] args) in C:\Users\spxc\Desktop\consoletest \XMLandCloudConsole\XMLandCloudConsole\Program.cs:line 29
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,     ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
4

0 回答 0