Skip to content

Commit 362092b

Browse files
authored
Merge pull request #5076 from JoshVanL/bindings-s3-bulk
[1.18] bindings/s3: bulk operations
2 parents 085b750 + 17fe81c commit 362092b

1 file changed

Lines changed: 175 additions & 0 deletions

File tree

  • daprdocs/content/en/reference/components-reference/supported-bindings

daprdocs/content/en/reference/components-reference/supported-bindings/s3.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ This component supports **output binding** with the following operations:
158158
- `get` : [Get object](#get-object)
159159
- `delete` : [Delete object](#delete-object)
160160
- `list`: [List objects](#list-objects)
161+
- `bulkGet`: [Bulk get objects](#bulk-get-objects)
162+
- `bulkCreate`: [Bulk create objects](#bulk-create-objects)
163+
- `bulkDelete`: [Bulk delete objects](#bulk-delete-objects)
161164

162165
### Create object
163166

@@ -515,6 +518,178 @@ The list of objects will be returned as JSON array in the following form:
515518
}
516519
```
517520

521+
### Bulk get objects
522+
523+
To download multiple objects in parallel, invoke the AWS S3 binding with a `POST` method and the following JSON body:
524+
525+
```json
526+
{
527+
"operation": "bulkGet",
528+
"data": {
529+
"items": [
530+
{ "key": "file1.txt" },
531+
{ "key": "file2.txt" },
532+
{ "key": "file3.txt", "filePath": "/tmp/file3.txt" }
533+
],
534+
"concurrency": 5
535+
}
536+
}
537+
```
538+
539+
The data parameters are:
540+
541+
- `items` - (required) an array of objects to download. Each item has:
542+
- `key` - (required) the name of the S3 object.
543+
- `filePath` - (optional) if provided, the object is streamed directly to this local file path instead of being returned in the response body.
544+
- `concurrency` - (optional) the maximum number of concurrent downloads. Defaults to `10`. Must be greater than `0`.
545+
546+
The component-level `encodeBase64` metadata option applies to bulk get. When set to `"true"`, object contents are base64-encoded before being returned in the response body. When `filePath` is specified, the file will contain base64-encoded text rather than raw bytes.
547+
548+
#### Example
549+
550+
{{< tabpane text=true >}}
551+
552+
{{% tab "Windows" %}}
553+
```bash
554+
curl -d "{ \"operation\": \"bulkGet\", \"data\": { \"items\": [{ \"key\": \"file1.txt\" }, { \"key\": \"file2.txt\" }], \"concurrency\": 5 } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
555+
```
556+
{{% /tab %}}
557+
558+
{{% tab "Linux" %}}
559+
```bash
560+
curl -d '{ "operation": "bulkGet", "data": { "items": [{ "key": "file1.txt" }, { "key": "file2.txt" }], "concurrency": 5 } }' \
561+
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
562+
```
563+
{{% /tab %}}
564+
565+
{{< /tabpane >}}
566+
567+
#### Response
568+
569+
The response body contains a JSON array with a result for each requested item. Each result includes a per-item error field for partial failure semantics — the operation succeeds overall, and individual failures are reported per key:
570+
571+
```json
572+
[
573+
{ "key": "file1.txt", "data": "contents of file1" },
574+
{ "key": "file2.txt", "data": "contents of file2" },
575+
{ "key": "missing.txt", "error": "object not found" }
576+
]
577+
```
578+
579+
When `filePath` is specified for an item, the `data` field is omitted and the content is written to the specified file.
580+
581+
### Bulk create objects
582+
583+
To upload multiple objects in parallel, invoke the AWS S3 binding with a `POST` method and the following JSON body:
584+
585+
```json
586+
{
587+
"operation": "bulkCreate",
588+
"data": {
589+
"items": [
590+
{ "key": "file1.txt", "data": "Hello World" },
591+
{ "key": "file2.txt", "data": "Another file", "contentType": "text/plain" },
592+
{ "key": "file3.txt", "filePath": "/path/to/local/file.txt" }
593+
],
594+
"concurrency": 5
595+
}
596+
}
597+
```
598+
599+
The data parameters are:
600+
601+
- `items` - (required) an array of objects to upload. Each item has:
602+
- `key` - (required) the name for the S3 object.
603+
- `data` - the content to upload. Either `data` or `filePath` must be provided.
604+
- `filePath` - a local file path to upload from. Either `data` or `filePath` must be provided.
605+
- `contentType` - (optional) the MIME type of the object.
606+
- `concurrency` - (optional) the maximum number of concurrent uploads. Defaults to `10`. Must be greater than `0`.
607+
608+
The component-level `decodeBase64` metadata option applies to bulk create. When set to `"true"`, the input is decoded from base64 before uploading to S3. This applies to both inline `data` fields and content read from `filePath` — use `filePath` with `decodeBase64` only when the file itself contains base64-encoded content.
609+
610+
#### Example
611+
612+
{{< tabpane text=true >}}
613+
614+
{{% tab "Windows" %}}
615+
```bash
616+
curl -d "{ \"operation\": \"bulkCreate\", \"data\": { \"items\": [{ \"key\": \"file1.txt\", \"data\": \"Hello World\" }, { \"key\": \"file2.txt\", \"data\": \"Another file\" }] } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
617+
```
618+
{{% /tab %}}
619+
620+
{{% tab "Linux" %}}
621+
```bash
622+
curl -d '{ "operation": "bulkCreate", "data": { "items": [{ "key": "file1.txt", "data": "Hello World" }, { "key": "file2.txt", "data": "Another file" }] } }' \
623+
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
624+
```
625+
{{% /tab %}}
626+
627+
{{< /tabpane >}}
628+
629+
#### Response
630+
631+
The response body contains a JSON array with a result for each item, including the location of the created object or a per-item error:
632+
633+
```json
634+
[
635+
{ "key": "file1.txt", "location": "https://mybucket.s3.us-west-2.amazonaws.com/file1.txt" },
636+
{ "key": "file2.txt", "location": "https://mybucket.s3.us-west-2.amazonaws.com/file2.txt" },
637+
{ "key": "bad-file.txt", "error": "either data or filePath is required" }
638+
]
639+
```
640+
641+
### Bulk delete objects
642+
643+
To delete multiple objects in a single batch operation, invoke the AWS S3 binding with a `POST` method and the following JSON body:
644+
645+
```json
646+
{
647+
"operation": "bulkDelete",
648+
"data": {
649+
"keys": ["file1.txt", "file2.txt", "file3.txt"]
650+
}
651+
}
652+
```
653+
654+
The data parameters are:
655+
656+
- `keys` - (required) an array of object key names to delete. Must contain at least one key.
657+
658+
Bulk delete uses the S3 [DeleteObjects](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html) batch API. If more than 1,000 keys are provided, the request is automatically split into batches of 1,000.
659+
660+
#### Example
661+
662+
{{< tabpane text=true >}}
663+
664+
{{% tab "Windows" %}}
665+
```bash
666+
curl -d "{ \"operation\": \"bulkDelete\", \"data\": { \"keys\": [\"file1.txt\", \"file2.txt\"] } }" http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
667+
```
668+
{{% /tab %}}
669+
670+
{{% tab "Linux" %}}
671+
```bash
672+
curl -d '{ "operation": "bulkDelete", "data": { "keys": ["file1.txt", "file2.txt"] } }' \
673+
http://localhost:<dapr-port>/v1.0/bindings/<binding-name>
674+
```
675+
{{% /tab %}}
676+
677+
{{< /tabpane >}}
678+
679+
#### Response
680+
681+
The response body contains a JSON array with a result for each key, including a per-item error field for partial failure semantics:
682+
683+
```json
684+
[
685+
{ "key": "file1.txt" },
686+
{ "key": "file2.txt" },
687+
{ "key": "no-permission.txt", "error": "Access Denied" }
688+
]
689+
```
690+
691+
An empty `error` field (or its absence) indicates successful deletion.
692+
518693
## Related links
519694

520695
- [Basic schema for a Dapr component]({{% ref component-schema %}})

0 commit comments

Comments
 (0)