我尝试使用RAmazonS3 package中的listBuckets
功能,但获取HTTP/1.1 403 Forbidden
。
首先,我按照the manual:
中的说明设置身份验证选项options(AmazonS3 = c('login' = 'secret'))
我用我的访问密钥ID(20个字符)替换login
,用我的秘密访问密钥(40个字符)替换secret
。当我运行listBuckets()
时,我收到以下错误:
Error in UseMethod("xmlSApply") :
no applicable method for 'xmlSApply' applied to an object of class "NULL"
它没有返回任何数据,因此不能正确连接。深入研究getURL
内的listBuckets
电话。该行的输出是:
* About to connect() to proxy proxyname.domain.com port xx (#0)
* Trying xxx.xxx.xxx.xxx... * connected
* Connected to proxyname.domain.com (xxx.xxx.xxx.xxx) port xx (#0)
> GET http://s3.amazonaws.com HTTP/1.1
Host: s3.amazonaws.com
Accept: */*
Proxy-Connection: Keep-Alive
Date: Fri, 12 Sep 2014 09:02:41 EDT
Authorization: AWS [login]:[unknown 27-character code]=
< HTTP/1.1 403 Forbidden
< x-amz-request-id: [unknown 16-character code]
< x-amz-id-2: [unknown 64-character code]
< Content-Type: application/xml
< Transfer-Encoding: chunked
< Date: Fri, 12 Sep 2014 13:02:40 GMT
< Server: AmazonS3
< Cache-Control: proxy-revalidate
< Proxy-Connection: Keep-Alive
< Connection: Keep-Alive
<
* Connection #0 to host proxyname.domain.com left intact
我出错的任何想法?
我不确定login
使用什么值,所以我还尝试了我的AWS账户名称,我的AWS账户用户名,以及字面上的“登录”#39; ,但得到类似的错误。
在找到RAmazonS3包之前,我开始使用AWS Command Line Interface编写自己的S3api函数。从R。
调用AWS CLI时,我能够成功列出存储桶及其对象sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RCurl_1.95-4.3 bitops_1.0-6 RAmazonS3_0.1-5
loaded via a namespace (and not attached):
[1] digest_0.6.4 tools_3.1.1 XML_3.98-1.1
答案 0 :(得分:1)
在大多数情况下,该包适用:
login = AWS密钥
secret = AWS秘密访问密钥
实施例: markus_test是一个没有公开权限的新创建的存储桶
auth <- c("AKIAJN6VFFXXXXXXXXXX" ="d95ij4uy0i6n+auvhwLLP6VQiz27OdXXXXXXXXXX")
listBucket("markus_test", auth)`
Key LastModified ETag Size
1 rmr2_example.R 2014-09-15 23:38:48 c7f4544cf972bed52fa84164cf2505bf 1248
Owner.ID Owner.DisplayName
1 2a22982b6e7216f42abd2e8848f07a8ada0b1c11318dc8331aee068f29b7765d markusataws
StorageClass
1 STANDARD
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RAmazonS3_0.1-5
loaded via a namespace (and not attached):
[1] digest_0.6.4 RCurl_1.95-4.3 tools_3.1.1 XML_3.98-1
答案 1 :(得分:1)
重复上述评论中的内容;我注意到连接到AWS服务的大多数R-package都已过时。所以我创建了一个新的包AWSConnect,允许用户使用S3和EC2进行大多数基本操作。在该包中,函数s3.ls()
旨在列出S3上的存储桶。
请随时使用,并报告任何错误/请求/问题