Skip to contents

Uploads the specified files to a NocoDB server as attachments via its POST /api/v2/storage/upload API endpoint. Uploaded files are stored under /nc/uploads/ in the configured object storage bucket (if one is set up) or directly on the server's filesystem.

Usage

upload_attachments(
  paths,
  types = mime::guess_type(paths),
  names = NULL,
  upload_path = "r",
  origin = pal::pkg_config_val("origin"),
  email = pal::pkg_config_val("email"),
  password = pal::pkg_config_val("password"),
  api_token = pal::pkg_config_val("api_token"),
  max_tries = 5L,
  verbosity = NULL
)

Arguments

paths

character()
Paths to the files to be uploaded.

types

character()
Media type(s) of the uploaded files. A character vector of the same length as paths.

names

character()
File names to assign to the uploaded files. A character vector of the same length as paths or NULL. If NULL, the original file names from paths are used. Note that a random string like _NnW3C is always appended to the resulting file name before its file type suffix, so names = "some-pic.jpg" will result in a file name like some-pic_NnW3C.jpg, for example.

upload_path

character(1)
Destination path to store the uploaded file(s) at. Always interpreted relative to the directory /nc/uploads/ (which is hardcoded in NocoDB's source code). Note that the characters . and ? are replaced with _ by the API.

origin

character(1)
NocoDB server origin.

email

character(1)
E-mail address of the NocoDB user to authenticate with.

password

character(1)
Password of the NocoDB user to authenticate with.

api_token

character(1)
NocoDB API token. Takes precedence over email and password if provided.

max_tries

integer(1)
Maximum number of attempts to retry in case of an HTTP error.

verbosity

How much information to print? This is a wrapper around req_verbose() that uses an integer to control verbosity:

  • 0: no output

  • 1: show headers

  • 2: show headers and bodies

  • 3: show headers, bodies, and curl status messages.

Use with_verbosity() to control the verbosity of requests that you can't affect directly.

Value

A tibble containing metadata about the uploaded attachments.