Skip to contents

[Experimental]

Usage

submission_draft_attachment_upload(
  iid,
  pid = get_default_pid(),
  fid = get_default_fid(),
  filename,
  file,
  content_type = NULL,
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  retries = get_retries()
)

Arguments

iid

The instance_id, a UUID, as returned by submission_list.

pid

The numeric ID of the project, e.g.: 2.

Default: get_default_pid.

Set default pid through ru_setup(pid="...").

See vignette("Setup", package = "ruODK").

fid

The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: get_default_fid.

Set default fid through ru_setup(fid="...").

See vignette("Setup", package = "ruODK").

filename

(character) The name of the expected file slot, as given by submission_draft_attachment_list().

file

(character) Path to a local file whose bytes are uploaded to the expected file slot.

content_type

(character) The MIME type sent as Content-Type header. Default: NULL, which sends "application/octet-stream".

url

The ODK Central base URL without trailing slash.

Default: get_default_url.

Set default url through ru_setup(url="...").

See vignette("Setup", package = "ruODK").

un

The ODK Central username (an email address). Default: get_default_un. Set default un through ru_setup(un="..."). See vignette("Setup", package = "ruODK").

pw

The ODK Central password. Default: get_default_pw. Set default pw through ru_setup(pw="..."). See vignette("Setup", package = "ruODK").

retries

The number of attempts to retrieve a web resource.

This parameter is given to RETRY(times = retries).

Default: 3.

Value

A list with a single element success (TRUE) as per the ODK Central API docs.

Details

To upload a binary to an expected file slot of a Draft Submission, POST the binary to its endpoint. Supply a content_type if you have one.

Examples

if (FALSE) { # \dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")

fl <- form_list()
fid <- fl$fid[[1]]

sl <- submission_draft_list(fid = fid)
iid <- sl$instance_id[[1]]

submission_draft_attachment_upload(
  iid,
  fid = fid,
  filename = "photo.jpg",
  file = "/path/to/photo.jpg"
)
} # }