简体   繁体   English

使用Power-shell对Amazon Web服务进行RESTful调用

[英]Making a RESTful call to Amazon Web service using Power-shell

I am trying to collect data from amazon web services. 我正在尝试从亚马逊网络服务收集数据。 Every time I make the call I get back a 403 Forbidden. 每次拨打电话时,我都会返回403 Forbidden。

This is what my code looks like (the link is jumbled): 这是我的代码的样子(链接混乱):

Invoke-RestMethod -Uri " https://hosted-data-work.s3.amazonaws.com/20161121T220310.324/dw_split/73610000000000001/assignment_fact/part00101.gzAWSAccessKeyId=ASIAJVX3JXfd5dfdfRKJNGM74Q&Expires=1479839499&Signature=J4JdyX53AwH6wExVmoVAtkweCEI%3D&resp222onse-contentdisposition=inline%3B%20filename%3D%22assignment_fact-00000-095582fd.gz%22%3B&x-amz-security-token=bluh " -Method Get 调用-RestMethod -uri“ https://hosted-data-work.s3.amazonaws.com/20161121T220310.324/dw_split/73610000000000001/assignment_fact/part00101.gzAWSAccessKeyId=ASIAJVX3JXfd5dfdfRKJNGM74Q&Expires=1479839499&Signature=J4JdyX53AwH6wExVmoVAtkweCEI%3D&resp222onse-contentdisposition=inline%3B% 20filename%3D%22assignment_fact-00000-095582fd.gz%22%3B&x-amz-security-token = bluh “-方法获取

The link above is a download file. 上面的链接是一个下载文件。 I just want to get the data the simplest way possible. 我只想以最简单的方式获取数据。 What else do I need to add in the call? 我还需要在通话中添加什么? I have no clue about aws! 我对aws一无所知!

How did you generate that URL? 您是如何生成该URL的? It looks like a presigned URL, which means the authorization for accessing the object will be granted based on the credentials used when presigning. 它看起来像一个预签名的URL,这意味着将根据预签名时使用的凭据来授予访问对象的授权。 There are a couple of possible reasons that could be giving you a not authorized response: 有两种可能的原因可能会给您未经授权的答复:

  1. The credentials used to generate the presigned URL do not actually have permissions to read the object. 用于生成预签名URL的凭据实际上没有读取该对象的权限。 Double check your IAM policies and/or ACLs for the bucket and the IAM user which generated the URL. 仔细检查生成URL的存储桶和IAM用户的IAM策略和/或ACL。
  2. The signature got truncated/corrupted between the the time you generated the presigned URL and the time you tried to use it. 在生成预签名URL的时间与尝试使用它的时间之间,签名被截断/损坏。 Try logging the url when you generate it and again when you use it and compare to make sure they match exactly. 尝试在生成网址时记录该网址,并在使用该网址时再次进行记录,并进行比较以确保它们完全匹配。
  3. Presigned URLs expire after a specified validity period which cannot be longer than 1 week. 预设的URL在指定的有效期(不能超过1周)后过期。 Make sure you are generating a fresh URL when needed and setting the expiration appropriately. 确保在需要时生成新的URL,并适当设置到期时间。

Any of those could be causing the result you're seeing. 这些都可能导致您看到的结果。

I was misinformed and took a bad approach at this problem. 我被误导了,对这个问题采取了不好的方法。 I did not know I can simply download the file to my computer. 我不知道我可以简单地将文件下载到我的计算机上。 I though it had to be transferred from bucket to bucket, then to my computer. 虽然我必须将它从一个存储桶转移到另一个存储桶,然后再传输到我的计算机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM