-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from jread-usgs/master
update to file replace/remove
- Loading branch information
Showing
13 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
multi_file_body <- function(files){ | ||
body = list() | ||
for(i in 1:length(files)){ | ||
if(!file.exists(files[i])){ | ||
stop('This file does not exist or cannot be accessed: ', files[i]) | ||
} | ||
|
||
body[[paste0('file', i)]] = upload_file(files[i]) | ||
} | ||
names(body) = rep('file', length(body)) | ||
return(body) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#'@title Remove all files associated with an item | ||
#'@param item_id a sciencebase item identifier | ||
#'@param session Authenticated session object (from \link{authenticate_sb}) | ||
#'@description Removes existing files associated with an item. | ||
#'@export | ||
item_rm_files <- function(item_id, session){ | ||
item_update(item_id,list('files'=vector()), session = session) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#'@title Replace files associated with an item | ||
#'@param item_id a sciencebase item identifier | ||
#'@param files a character vector of file paths | ||
#'@param session Authenticated session object (from \link{authenticate_sb}) | ||
#'@description replaces existing files associated with an item with a new one. | ||
#'(Currently does not support multi-file uploads.) | ||
#'This function will not append an existing collection of files. If that | ||
#'is desired, use \code{\link{item_append_file}} | ||
#'@export | ||
item_replace_files <- function(item_id, files, session){ | ||
item_rm_files(item_id, session) | ||
item_append_files(id = item_id, filename = files, session) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/item_replace_files.R | ||
\name{item_replace_files} | ||
\alias{item_replace_files} | ||
\title{Replace files associated with an item} | ||
\usage{ | ||
item_replace_files(item_id, files, session) | ||
} | ||
\arguments{ | ||
\item{item_id}{a sciencebase item identifier} | ||
|
||
\item{files}{a character vector of file paths} | ||
|
||
\item{session}{Authenticated session object (from \link{authenticate_sb})} | ||
} | ||
\description{ | ||
replaces existing files associated with an item with a new one. | ||
(Currently does not support multi-file uploads.) | ||
This function will not append an existing collection of files. If that | ||
is desired, use \code{\link{item_append_file}} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/item_remove_files.R | ||
\name{item_rm_files} | ||
\alias{item_rm_files} | ||
\title{Remove all files associated with an item} | ||
\usage{ | ||
item_rm_files(item_id, session) | ||
} | ||
\arguments{ | ||
\item{item_id}{a sciencebase item identifier} | ||
|
||
\item{session}{Authenticated session object (from \link{authenticate_sb})} | ||
} | ||
\description{ | ||
Removes existing files associated with an item. | ||
} | ||
|