item_file_download: Download files attached to item

View source: R/item_file_download.R

item_file_downloadR Documentation

Download files attached to item

Description

Function to downlod files attached to an item on SB. Either files can be specified directly using the names and destinations parameters, or a dest_dir can be supplied where all attached files will be written with the names as stored on SB.

Usage

item_file_download(
  sb_id,
  ...,
  names,
  destinations,
  dest_dir = getwd(),
  session = current_session(),
  overwrite_file = FALSE
)

Arguments

sb_id

An sbitem object or a character ScienceBase ID corresponding to the item

...

Additional parameters are passed on to GET, POST, HEAD, PUT, or DELETE

names

String vector list of file names attached to item that you wish to download.

destinations

String vector list of destinations for requested files. Must be same length as names

dest_dir

A directory path for saving files when names destinations parameter is not specified.

session

Session object from authenticate_sb. Defaults to anonymous or last authenticated session

overwrite_file

Boolean indicating if file should be overwritten if it already exists locally

Value

Character vector of full paths to local files

Examples

## Not run: 

#downloads all files attached to this item
item_file_download('627f1572d34e3bef0c9a30d8', dest_dir=tempdir())

#downloads a specific file attached to this item
item_file_download('627f1572d34e3bef0c9a30d8', names='example.txt',
		destinations=file.path(tempdir(), 'out.txt'))
		

## End(Not run)

sbtools documentation built on May 1, 2023, 1:07 a.m.