cloudyr / aws.s3

Amazon Simple Storage Service (S3) API Client
https://cloud.r-project.org/package=aws.s3
381 stars 147 forks source link

Allow direct passage of key and secret into s3read_using() #358

Closed ben519 closed 4 years ago

ben519 commented 4 years ago

Thanks for this awesome package. I'm currently using version 0.3.21 on R 4.0.0.

I would like the ability to pass my key and secret directly into s3read_using(), avoiding the need to create environment variables. For example, I want to do something like this

foo <- aws.s3::s3read_using(
      FUN = function(x) data.table::fread(x, na.strings = ""), 
      bucket = "my-bucket",
      object = "foo.csv",
      key = "abc",
      secret = "def"
    )

Currently this generates an "unused arguments" error because ... in the function gets passed on to FUN().

Thanks!

s-u commented 4 years ago

The syntax is

foo <- aws.s3::s3read_using(
      FUN = data.table::fread, 
      na.strings = "",
      bucket = "my-bucket",
      object = "foo.csv",
      opts = list(key = "abc",  secret = "def")
    )