Get the full name of a versioned cloud object
cloud_object_name.Rd
Obtain the full name (e.g.
timor-landings-v2_metadata__20210326084600_54617b3__.json
) of a cloud
storage object. If there are more than one object matching the prefix,
version, and extension, a vector with all the names is returned.
Usage
cloud_object_name(
prefix,
version = "latest",
extension = "",
provider,
exact_match = FALSE,
options
)
Arguments
- prefix
string indicating the prefix of the object
- version
either "latest" or the specific version string generated by add_version when the file was uploaded to the cloud provider
- extension
extension of the desired file. Use an empty string "" to return all extensions founds
- provider
cloud provider to use, either "gcs" or "aws"
- exact_match
logical indicating whether the prefix should be matched exactly
- options
named list with cloud provider options, see details
Value
A string vector with the object names in the cloud storage that match the prefix, the version, and the extension indicated in the parameters
Details
Google Cloud Services
For Google Cloud Services ("gcs") options must be a list with two fields:
bucket
with the bucketname (character) you are uploading to, and
service_account_key
with the contents of the authentication json file you
have downloaded from your Google Project (if cloud_storage_authenticate has
not been called before).
This function uses googleCloudStorageR::gcs_upload under the hood to upload the file.
Examples
#' # Google Cloud Services
if (FALSE) { # \dontrun{
authentication_details <- readLines("location_of_json_file.json")
# obtain the latest version of all files corresponding to timor-landings-v2
cloud_object_name(
prefix = "timor-landings-v2",
version = "latest",
provider = "gcs",
options = list(
service_account_key = authentication_details,
bucket = "my-bucket"
)
)
# obtain a specific version of the structured data from timor-landings-v2
cloud_object_name(
prefix = "timor-landings-v2_raw",
version = "20210326084600_54617b",
extension = "csv",
provider = "gcs",
options = list(
service_account_key = authentication_details,
bucket = "my-bucket"
)
)
} # }