Skip to content

Commit 87cf79e

Browse files
committed
feature: implement undocumented R2 startAfter API
This adds the `startAfter` list option which is implemented, however undocumented. This is equivalent to the `marker` field in the s3 api.
1 parent 1f37894 commit 87cf79e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

worker/src/r2/builder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ pub struct ListOptionsBuilder<'bucket> {
379379
pub(crate) edge_bucket: &'bucket EdgeR2Bucket,
380380
pub(crate) limit: Option<u32>,
381381
pub(crate) prefix: Option<String>,
382+
pub(crate) start_after: Option<String>,
382383
pub(crate) cursor: Option<String>,
383384
pub(crate) delimiter: Option<String>,
384385
pub(crate) include: Option<Vec<Include>>,
@@ -397,6 +398,12 @@ impl ListOptionsBuilder<'_> {
397398
self
398399
}
399400

401+
/// Start listing after this key.
402+
pub fn start_after(mut self, start_after: impl Into<String>) -> Self {
403+
self.start_after = Some(start_after.into());
404+
self
405+
}
406+
400407
/// An opaque token that indicates where to continue listing objects from. A cursor can be
401408
/// retrieved from a previous list operation.
402409
pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
@@ -437,6 +444,7 @@ impl ListOptionsBuilder<'_> {
437444
js_object! {
438445
"limit" => self.limit,
439446
"prefix" => self.prefix,
447+
"startAfter" => self.start_after.map(JsValue::from),
440448
"cursor" => self.cursor,
441449
"delimiter" => self.delimiter,
442450
"include" => self

worker/src/r2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl Bucket {
104104
edge_bucket: &self.inner,
105105
limit: None,
106106
prefix: None,
107+
start_after: None,
107108
cursor: None,
108109
delimiter: None,
109110
include: None,

0 commit comments

Comments
 (0)