Closed lappazos closed 2 years ago
You can use gcs_get_object()
with meta=TRUE
to check just the headers.
gcs_get_object("not-there", meta = TRUE)
#ℹ 2022-06-23 18:37:24 > Request Status Code: 404
#Error in `abort_http()`:
#! http_404 No such object: mark-edmondson-public-files/not-there
It creates a custom error http_404
which you can catch if you want your code to carry on, similar to:
tryCatch(gcs_get_object("not-there", meta = TRUE), http_404 = function(e) FALSE)
# [1] FALSE
How do I check if a file in a bucket exists?