From 8f6023c361ada007b5a0691484590f80aa598fff Mon Sep 17 00:00:00 2001 From: Josiah Parry Date: Wed, 3 Jul 2024 14:26:32 -0400 Subject: [PATCH] update attachments --- R/attachments.R | 8 ++++++++ dev/attachments-demo.R | 23 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/R/attachments.R b/R/attachments.R index d1cd391..e631f97 100644 --- a/R/attachments.R +++ b/R/attachments.R @@ -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, @@ -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.") @@ -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" ) diff --git a/dev/attachments-demo.R b/dev/attachments-demo.R index 158b05f..a90e187 100644 --- a/dev/attachments-demo.R +++ b/dev/attachments-demo.R @@ -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" +# )