This commit is contained in:
hong-revo 2018-05-15 07:35:28 +10:00
Родитель c8bbcdb409
Коммит 5b795132d9
2 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -8,41 +8,52 @@ get_storage_properties <- function(object, ...)
#' @export
get_storage_properties.storage_endpoint <- function(object)
{
do_storage_op(object$url, "", options=list(restype="service", comp="properties"))
do_storage_call(object$url, "", options=list(restype="service", comp="properties"),
key=object$key, sas=object$sas, api_version=object$api_version)
}
#' @export
get_storage_properties.blob_container <- function(object)
{
do_container_op(object, options=list(restype="container"))
res <- do_container_op(object, options=list(restype="container"), http_status_handler="pass")
httr::stop_for_status(res, )
httr::headers(res)
}
#' @export
get_storage_properties.file_share <- function(object)
{
do_container_op(object, options=list(restype="share"))
res <- do_container_op(object, options=list(restype="share"), http_status_handler="pass")
httr::stop_for_status(res)
httr::headers(res)
}
#' @export
get_azure_blob_properties <- function(container, blob)
{
do_container_op(container, blob, http_verb="HEAD")
res <- do_container_op(container, blob, http_verb="HEAD", http_status_handler="pass")
httr::stop_for_status(res)
httr::headers(res)
}
#' @export
get_azure_file_properties <- function(share, file)
{
do_container_op(share, file, http_verb="HEAD")
res <- do_container_op(share, file, http_verb="HEAD", http_status_handler="pass")
httr::stop_for_status(res)
httr::headers(res)
}
#' @export
get_azure_dir_properties <- function(share, dir)
{
do_container_op(share, dir, options=list(restype="directory"), http_verb="HEAD")
res <- do_container_op(share, dir, options=list(restype="directory"), http_verb="HEAD", http_status_handler="pass")
httr::stop_for_status(res)
httr::headers(res)
}

Просмотреть файл

@ -43,7 +43,8 @@ do_storage_call <- function(endpoint_url, path, options=list(), headers=list(),
if(handler != "pass")
{
handler <- get(paste0(handler, "_for_status"), getNamespace("httr"))
handler(response)
handler(response, paste0("complete Storage Services operation. Message:\n",
sub("\\.$", "", storage_error_message(response))))
# if file was written to disk, printing content(*) will read it back into memory!
if(inherits(response$content, "path"))
@ -61,6 +62,18 @@ do_storage_call <- function(endpoint_url, path, options=list(), headers=list(),
}
storage_error_message <- function(response)
{
cont <- suppressMessages(httr::content(response))
if(inherits(cont, "xml_node"))
{
cont <- xml2::as_list(cont)
paste0(unlist(cont), collapse="\n")
}
else NULL
}
sign_request <- function(key, verb, url, headers, api)
{
acct_name <- sub("\\..+$", "", url$host)