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
Implement Object operations for Spaces API #146
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work.
- Add yourself as author to DESCRIPTION file
- pulled your branch down - looks like man/spaces_delete_object.Rd was updated, run
document()
or equiv. again and push that
R/spaces.R
Outdated
#' with the spaces key. If missing, defaults to value stored in an environment | ||
#' variable \code{DO_SPACES_SECRET_KEY}. | ||
#' @param ... Additional argument passed to \code{\link[aws.s3]{get_object}} | ||
#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amoeba if you want to include @author <youremail>
tags for the functions you write go ahead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I'm okay not doing this.
R/spaces.R
Outdated
#' # basename | ||
#' spaces_put_object("./some-file.txt", space = "my-space") | ||
#' } | ||
spaces_put_object <- function(file, object = basename(file), space, spaces_key = NULL, spaces_secret = NULL, ...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function doesn't error well if the file doesn't exist - maybe an internal check for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger.
R/spaces.R
Outdated
#' @examples | ||
#' \dontrun{ | ||
#' spaces_put_object("./some-file.txt", "my-object", "my-space") | ||
#' spaces_get_object("my-object", "my-space") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding an example of how to convert the raw bytes to text would be good, e.g, rawToChar(x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion! Will do.
R/spaces.R
Outdated
#' spaces_put_object("./some-file.txt", "my-object", "my-space") | ||
#' spaces_head_object("my-object", "my-space") | ||
#' } | ||
spaces_head_object <- function(object, space, spaces_key = NULL, spaces_secret = NULL, ...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toughts on the output structure from this function? Maybe make it into a named list instead? just via attributes(x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that.
Now also shows the user an example of converting the response to its character representation
Thanks for the comments. Will update this PR. |
Since this is a call to a non-exported s3 method from xml2 and aws.s3 imports xml2, I think we're good in terms of this working as intended
@amoeba sorry for delay - getting to looking this over hopefully today |
@@ -10,6 +10,8 @@ Authors@R: c( | |||
person("Hadley", "Wickham", role = "aut", email = "hadley@rstudio.com"), | |||
person("Winston", "Chang", role = "aut", email = "winston@stdout.org"), | |||
person("Bob", "Rudis", role = "ctb", email = "bob@rudis.net"), | |||
person("Bryce", "Mecum", role = "ctb", email = "brycemecum@gmail.com", | |||
comment = c("ORCID" = "0000-0002-0381-3766")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, will gather ORCIDs for others later
R/spaces_acl_get.R
Outdated
base_url = spaces_base, | ||
...) | ||
|
||
# if (!requireNamespace("xml2")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amoeba i forget, did you mean to leave this block commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. I did not! Will fix.
@amoeba is I'm getting an error on every try, checked that my env vars are there. SO with verbose curl output i'm seeing space_create('new_space_name', config=httr::verbose())
-> PUT /new_space_name/ HTTP/1.1
-> Host: nyc3.digitaloceanspaces.com
-> User-Agent: libcurl/7.54.0 r-curl/3.1 httr/1.3.1
... cut out some stuff
<- HTTP/1.1 400 Bad Request
<- Date: Thu, 25 Jan 2018 02:37:06 GMT
<- Content-Length: 153
<- Content-Type: text/plain; charset=utf-8 so the URL seems like whereas in creating one in the DO platform, and the API docs say the same, looks like the URL should be of the form
thoughts? does it work for you? |
R/spaces_acl_put.R
Outdated
#' spaces_object_put("some-file.txt", space = "my-space") | ||
#' | ||
#' # You can get a copy of the ACL | ||
#' acl <- spaces_acl_get("some-file.txt", "my-space") %>% read_xml() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in examples, with Suggested pkgs, should use them conditionally on whether user has the pkg.
so
if (requireNamespace("xml2")) {
do the thing
}
and inside that block (if user has xml2 installed) namespace xml2
calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting. I can certainly do that.
R/spaces_acl_put.R
Outdated
#' acl <- spaces_acl_get("some-file.txt", "my-space") %>% read_xml() | ||
#' | ||
#' # Modify it as needed, then update it | ||
#' spaces_acl_put("my-object", "my-space", acl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is my-object
supposed to be equivalent to some-file.txt
? if so could you change that, so peole can actually do the eg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a mistake. Fixed.
I couldn't get |
Thanks for taking a look. I really appreciated the letting us have a go at this and the helpful comments. I don't think I have ever been able to |
Hrm, > spaces_object_delete("GDP.csv", "test-analogsea")
[1] TRUE |
Glad delete works. Wonder if they changed how spaces create works since that fxn was originally made here? |
I wonder. I'll take a look at it. |
Looks like a limitation of # handle S3-compatible storage URLs
if (base_url != "s3.amazonaws.com") {
if (isTRUE(verbose) && url_style != "path") {
message("Non-AWS base URL requested. Switching to path-style URLs.")
}
... which looks like the cause of our problem here. |
ah, that could be it, right, i assume then it adds the bucket/space name after the base url |
yup |
bump @amoeba , are you waiting on me to do anything here? |
Hey @sckott thanks for the bump. This can be merged if you think so. I looked over all of the comments here and in the related issue and I think it's good to go. |
okay, will take another quick look |
@amoeba can you add |
Done! |
thanks for the rbuildignore fix. hmm, did you see my comment about |
I did. I was thinking that, since this PR is just for the Object API operations that I/we'd work on that elsewhere. It'll require either an upstream |
right, forgot about that. yep, we'll deal with fixing create later. |
Description
This implements the first half of the operations listed in #140 which are the Spaces API operations related to Objects
Related Issue
#140
No tests yet, since all these tests require external calls. See discussion in #140