Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.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# 从本地主机上传S3?_C#_Amazon Web Services_Amazon S3_.net Core - Fatal编程技术网

C# 从本地主机上传S3?

C# 从本地主机上传S3?,c#,amazon-web-services,amazon-s3,.net-core,C#,Amazon Web Services,Amazon S3,.net Core,我正在跟踪下面的链接 将文件从本地计算机上载到VPC上的S3存储桶。该应用程序还在本地机器上测试和运行 var s3Client = new AmazonS3Client(RegionEndpoint.USEast2); var fileTransferUtility = new TransferUtility(s3Client); await fileTransferUtility.UploadAsync("c:\tmp\test.txt", "bucketName"); 但是,代码会出现以

我正在跟踪下面的链接 将文件从本地计算机上载到VPC上的S3存储桶。该应用程序还在本地机器上测试和运行

var s3Client = new AmazonS3Client(RegionEndpoint.USEast2);
var fileTransferUtility = new TransferUtility(s3Client);
await fileTransferUtility.UploadAsync("c:\tmp\test.txt", "bucketName");
但是,代码会出现以下错误

试图对无法访问的网络执行套接字操作

是否应该提供Url


这是Fiddler捕获的网络流量。但是,它会得到一个不同的代码异常

GET http://1xx.1xx.1xx.2xx/latest/meta-data/iam/security-credentials HTTP/1.1 Host: 1xx.1xx.1xx.2xx HTTP/1.1 503 Service Unavailable Cache-Control: no-cache Pragma: no-cache Content-Type: text/html; charset=utf-8 Proxy-Connection: Keep-Alive Connection: Keep-Alive Content-Length: 787 Network Error
Network Error (tcp_error)

A communication error occurred: "Operation timed out" The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
For assistance, contact your network support team.

我今天也犯了同样的错误,尽管我有一个有效的
$USERPROFILE\.aws\credentials
文件-实际上是因为
$USERPROFILE\AppData\Local\awstolkit\RegisteredAccounts.json
无法解密(不确定原因),这导致aws认为您没有本地凭据,并因此尝试与EC2元数据URL建立连接,该URL为?。在无法访问的本地开发计算机上。对我来说,删除
$USERPROFILE\AppData\Local\AWSToolkit\RegisteredAccounts.json
文件就成功了。FWIW,我只是通过阅读AWS SDK的源代码来解决这个问题…

尽管我有一个有效的
$USERPROFILE\.AWS\credentials
文件,但今天我还是遇到了相同的错误-实际上是因为
$USERPROFILE\AppData\Local\awstolkit\RegisteredAccounts.json
无法解密(不确定原因),这导致AWS认为您没有本地凭据,因此尝试连接到EC2元数据URL,该URL为?。在无法访问的本地开发计算机上。对我来说,删除
$USERPROFILE\AppData\Local\AWSToolkit\RegisteredAccounts.json
文件就成功了。FWIW,我只是通过阅读AWS SDK的源代码才弄明白这一点…

你能在没有密钥的情况下发布配置吗?我的下一步是快速跟踪Wireshark,看看它试图接触到什么。您是否在公司(或其他)防火墙后面?@TheSoftwareJedi,您知道在哪里可以找到配置/配置文件吗?在Windows计算机上找不到.aws文件夹。在Windows上,凭据文件位于C:\Users\\\.aws\credentials。如果主文件夹中缺少.aws目录,则您尚未运行命令“aws configure”来设置aws环境。@JohnHanley,它不在那里,因此我运行
aws configure
并进行设置(仅针对
区域
)你能在没有密钥的情况下发布你的配置吗?我下一步要做的就是快速跟踪Wireshark,看看它想接触到什么。您是否在公司(或其他)防火墙后面?@TheSoftwareJedi,您知道在哪里可以找到配置/配置文件吗?在Windows计算机上找不到.aws文件夹。在Windows上,凭据文件位于C:\Users\\\.aws\credentials。如果主文件夹中缺少.aws目录,则您没有运行命令“aws configure”来设置您的aws环境。@JohnHanley,它不在那里,因此我运行
aws configure
并进行设置(仅针对
区域
),我收到了相同的神秘错误消息。您的回答让我通过删除$USERPROFILE\.aws目录并使用“aws configure”重新创建来解决我的问题。我收到了同样的神秘错误消息。您的响应使我通过删除$USERPROFILE\.aws目录并使用“aws configure”重新创建来解决我的问题
[default]
region = USWest2