diff --git a/NAMESPACE b/NAMESPACE index 2c778f1..16de0f1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(IsDisplayrCloudDriveAvailable) export(QDeleteFiles) export(QFileExists) export(QFileOpen) +export(QGetSharedUrl) export(QLoadData) export(QSaveData) export(RunSQL) diff --git a/R/DataMart.R b/R/DataMart.R index 16bb293..c15c08a 100644 --- a/R/DataMart.R +++ b/R/DataMart.R @@ -408,7 +408,7 @@ QGetSharedUrl <- function(filename) encode = "raw")) has.errored <- inherits(res, "try-error") - if (res$status_code == 404) + if (res$status_code == 404 || httr::content(res, as = "text") == "File not found") { stop("QGetSharedUrl has encountered an unknown error. ", "404: No such file exists. ", diff --git a/man/QGetSharedUrl.Rd b/man/QGetSharedUrl.Rd new file mode 100644 index 0000000..e71827b --- /dev/null +++ b/man/QGetSharedUrl.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/DataMart.R +\name{QGetSharedUrl} +\alias{QGetSharedUrl} +\title{Share an object} +\usage{ +QGetSharedUrl(filename) +} +\arguments{ +\item{filename}{character string. Name of the file that is being shared. +To reference a file in a subdirectory, use double backslashes after each folder (e.g "subdir\\file.csv").} +} +\value{ +Share URL as a string +} +\description{ +Gets the cloud drive share url for an object saved to the Displayr Cloud Drive. +} +\details{ +If the file has not previously been shared it will be shared else the already existing +share url will be returned. +} diff --git a/tests/testthat/test-datamart.R b/tests/testthat/test-datamart.R index 1fb0182..650194c 100644 --- a/tests/testthat/test-datamart.R +++ b/tests/testthat/test-datamart.R @@ -179,25 +179,6 @@ test_that("QGetSharedUrl: bad cases", { QGetSharedUrl("file_that_does_not_exist.rds"), "404: No such file exists" ) - - # 404 error with mocked POST - mocked.post <- function(...) { - list(status_code = 404) - } - with_mocked_bindings( - POST = mocked.post, - QGetSharedUrl("any_file.rds"), - .package = "httr" - ) |> - expect_error( - paste0( - "QGetSharedUrl has encountered an unknown error. ", - "404: No such file exists. ", - "The likely cause was an incorrect path preceding the filename, ", - "or insufficient access to the file path." - ), - fixed = TRUE - ) }) test_that("Delete Data",