简体   繁体   中英

Cannot access file on S3 using R

access_key<-"**************"
secret_key<-"****************"

bucket<- "temp"
filename<-"test.csv"


Sys.setenv("AWS_ACCESS_KEY_ID" = access_key,
       "AWS_SECRET_ACCESS_KEY" = secret_key )

buckets<-(bucketlist())
getbucket(bucket)


usercsvobj <-get_object(bucket = "","s3://part112017rscriptanddata/test.csv")
csvcharobj <- rawToChar(usercsvobj)
con <- textConnection(csvcharobj)
data <- read.csv(con)

I am a able to see the contents of the bucket, but fail to read the csv as a data frame.

[1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error>
<Code>PermanentRedirect</Code><Message>The bucket you are attempting to 
access must be addressed using the specified endpoint. Please send all 
future requests to this endpoint.</Message><Bucket>test.csv</Bucket>
<Endpoint>test.csv.s3.amazonaws.com</Endpoint>
<RequestId>76E9C6B03AC12D8D</RequestId>
 <HostId>9Cnfif4T23sJVHJyNkx8xKgWa6/+
  Uo0IvCAZ9RkWqneMiC1IMqVXCvYabTqmjbDl0Ol9tj1MMhw=</HostId></Error>"

I am using the cran versioin of the aws.S3 package .

我能够使用以下命令从本地r或通过r stuio服务器从S3存储桶中读取:data <-read.csv(textConnection(getURL(“ https://s3-eu-west-1.amazonaws.com/'yourbucket '/'yourFileName“)),sep =”,“,标头= TRUE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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