0

I want to use connection arguments multiple times in R but I can't find away to declare and then reuse them with the aws.s3 library.

For example - this works:

library(aws.s3)

object_exists(
      object = "some_object_name"
      ,bucket = "some_bucket_name"
      ,region = "some_region_name"
      ,key = "some_key"
      ,secret = "some_secret
    )

But this does not:

    library(aws.s3)

    connection_args <- list(
      object = "some_object_name"
      ,bucket = "some_bucket_name"
      ,region = "some_region_name"
      ,key = "some_key"
      ,secret = "some_secret"
    )

    object_exists(connection_args)
Sanchez333
  • 318
  • 3
  • 11
  • 1
    If you want to call any R function with a list of parameters, you could use `do.call`, so, for example. `do.call("object_exists", connection_args)`. The duplicate link shows other methods as well. – MrFlick Apr 27 '23 at 14:29
  • This works thanks. I was hoping to have a bit more flexibility - like remove the object but reuse the other connections arguments to check for several different objects but with do.call I can only send all the arguments, I can't do like object_exists(object = "some_object", connection_args) – Sanchez333 Apr 27 '23 at 14:36
  • Unfortunately this question has been closed, despite it relating specifically to the aws.s3 package and not to generic listing of parameters. Please see the second comment. If anyone does know how something can be achieved to pass these args through headers perhaps, please leave a comment. Thanks. – Sanchez333 Apr 27 '23 at 14:40
  • 1
    You can see the [source code for that function](https://github.com/cloudyr/aws.s3/blob/621e0adc85abaa414814569ffe7dd28334318dc3/R/head_object.R#L49). What you want is not something that package supports. You can [file an issue](https://github.com/cloudyr/aws.s3/issues) with the package author if you want them to add new features, or you can use the standard R mechanisms to update your list with something like `modifyList(connection_args, list(object="some_object"))` – MrFlick Apr 27 '23 at 14:44

0 Answers0