Skip to content

Commit

Permalink
update attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Jul 3, 2024
1 parent a2fbd49 commit 8f6023c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
8 changes: 8 additions & 0 deletions R/attachments.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
query_layer_attachments <- function(
x,
definition_expression = "1=1",
attachments_definition_expression = NULL,
object_ids = NULL,
global_ids = NULL,
attachment_types = NULL,
Expand All @@ -50,6 +51,11 @@ query_layer_attachments <- function(
# Ignored arguments for now:
# returnMetadata, size,
) {
check_string(definition_expression, allow_null = TRUE)
check_string(attachments_definition_expression, allow_null = TRUE)
check_character(global_ids, allow_null = TRUE)
# TODO validate that object_ids is a vector

# ensure that attachments are available.
if (!x[["hasAttachments"]]) {
cli::cli_abort("{.arg layer} does not support attachments.")
Expand Down Expand Up @@ -86,8 +92,10 @@ query_layer_attachments <- function(
# - common prefix
# - numeric value
definitionExpression = definition_expression,
attachmentsDefinitionExpression = attachments_definition_expression,
keywords = keywords,
returnUrl = TRUE,
returnMetadata = TRUE,
f = "json"
)

Expand Down
23 changes: 18 additions & 5 deletions dev/attachments-demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,26 @@ query_layer_attachments(
layer, "followup_status = 'needs_followup'"
)

# To find all of the attachmetns from after a point in time
# To find all of the attachments from after a point in time
query_layer_attachments(
layer, "start_time >= '2023-01-01'"
)

# to download the attachments:
res <- download_attachments(
att,
"dev/field_images"
# To find attachments with a name that starts with `image0`
query_layer_attachments(
layer,
attachments_definition_expression = "att_name like 'image0%'"
)

# Find attachments that contain "20221005"
query_layer_attachments(
layer,
attachments_definition_expression = "att_name like '%20221005%'"
)


# to download the attachments:
# res <- download_attachments(
# att,
# "dev/field_images"
# )

0 comments on commit 8f6023c

Please sign in to comment.