Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add these? #234

Closed
1 of 3 tasks
plroebuck opened this issue Jun 8, 2018 · 6 comments
Closed
1 of 3 tasks

Add these? #234

plroebuck opened this issue Jun 8, 2018 · 6 comments

Comments

@plroebuck
Copy link

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

Put your code here:

## load package
library("aws.s3")

## Returns size of S3 file, or NA if it does not exist
s3file.size <- function (object, bucket, ...) {
  suppressMessages(
    headObj <- head_object(object=object,
                           bucket=bucket,
                           ...)
  )
  if (as.logical(headObj)) {
    as.double(attr(headObj, "content-length"))
  } else {
    as.double(NA)
  }
}

## Returns TRUE if S32 file exists; otherwise, FALSE
s3file.exists <- function (object, bucket, ...) {
  suppressMessages(
    headObj <- head_object(object=object,
                           bucket=bucket,
                           ...)
  )
  as.logical(headObj)
}
@leeper
Copy link
Member

leeper commented Jun 8, 2018

I think you want the head_object() function, at least for the second case.

@plroebuck
Copy link
Author

Not sure I follow you. Code uses head_object() already...

@leeper
Copy link
Member

leeper commented Jun 8, 2018

I'm saying the added value is not clear to me.

@plroebuck
Copy link
Author

plroebuck commented Jun 8, 2018

Though head_object() exists, it's not exactly an obvious mapping for the package user;
I had to do several google searches, as well as figure out how to not have the output for nonexistent files show up. s3file.exists() is quite obvious as to what it does. It's value is exactly that. Additionally, my client code is implicitly documented -- doubt most people unfamiliar with your API would equate these two routines, requiring them to have to look up all this same information again.

DMMT

@leeper
Copy link
Member

leeper commented Jun 8, 2018

That's helpful. Thank you.

@leeper
Copy link
Member

leeper commented Jun 11, 2018

Thanks, again. This is now implemented as object_size() and object_exists().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants