Skip to content

Commit e6598b7

Browse files
committed
Extend snapshotting and forking page with ListObjects, GetObject and HeadObject info
1 parent 22a30e9 commit e6598b7

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

docs/buckets/snapshots-and-forks.mdx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,68 @@ def create_bucket_fork(tigris, bucket_name):
424424
</TabItem>
425425
</Tabs>
426426

427+
### Listing and Retrieving Objects from a Snapshot
428+
429+
Objects can be listed in a snapshot with the same ListObjectsV2 API call, with
430+
an additional header: `X-Tigris-Snapshot-Version: SNAPSHOT_VERSION`. Similarly,
431+
specific versions of an object in a particular snapshot can be retrieved with
432+
the same GetObject API call and header. The same approach also applies to
433+
HeadObject requests.
434+
435+
Below is an example of retrieving an object from a snapshot:
436+
437+
<Tabs groupId="languages">
438+
<TabItem value="go" label="Go">
439+
Example using the Go SDK `github.com/aws/aws-sdk-go-v2/service/s3`:
440+
441+
```go
442+
func getObjectFromSnapshot(ctx context.Context, client *s3.Client, bucket string, object string, snapshotVersion string) (*s3.GetObjectOutput, error) {
443+
return client.GetObject(ctx, &s3.GetObjectInput{Bucket: aws.String(bucket), Key: aws.String(object)}, func(options *s3.Options) {
444+
options.APIOptions = append(options.APIOptions, http.AddHeaderValue("X-Tigris-Snapshot-Version", snapshotVersion))
445+
})
446+
}
447+
```
448+
449+
</TabItem>
450+
451+
<TabItem value="js" label="JavaScript">
452+
Example using the AWS SDK for JavaScript v3:
453+
454+
```js
455+
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
456+
457+
async function getObjectFromSnapshot(client, bucket, key, snapshotVersion) {
458+
return client.send(
459+
new GetObjectCommand({
460+
Bucket: bucket,
461+
Key: key,
462+
$httpOptions: {
463+
headers: { "X-Tigris-Snapshot-Version": snapshotVersion },
464+
},
465+
}),
466+
);
467+
}
468+
```
469+
470+
</TabItem>
471+
<TabItem value="python" label="Python">
472+
Example using the Python SDK boto3:
473+
474+
```python
475+
def get_object_from_snapshot(s3_client, bucket_name, object_key, snapshot_version):
476+
def add_header(request, **kwargs):
477+
request.headers["X-Tigris-Snapshot-Version"] = snapshot_version
478+
s3_client.meta.events.register("before-sign.s3.GetObject", add_header)
479+
try:
480+
response = s3_client.get_object(Bucket=bucket_name, Key=object_key)
481+
return response
482+
finally:
483+
s3_client.meta.events.unregister("before-sign.s3.GetObject", add_header)
484+
```
485+
486+
</TabItem>
487+
</Tabs>
488+
427489
### Using a Forked Bucket
428490

429491
Forked buckets behave the same as regular buckets, and you can use the usual
@@ -432,6 +494,14 @@ tooling (AWS CLI or SDK) to work with them.
432494
The only restriction is that the parent bucket cannot be deleted while forked
433495
buckets depend on it.
434496

497+
### Authorization
498+
499+
Snapshotting and forking operations on existing buckets are limited to users who
500+
are bucket owners, organization admins, or have ReadOnly (or Editor) access to
501+
the buckets. This includes all operations mentioned above, such as creating a
502+
snapshot, creating a fork from a specific parent bucket, or listing objects in a
503+
snapshot.
504+
435505
## Limitations and Upcoming Functionality
436506

437507
### Current Limitations

docs/sdks/tigris/snapshots-and-forks.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ Forks can be created using the `createBucket` function and by passing
8383
import { createBucket } from "@tigrisdata/storage";
8484

8585
const createFork = await createBucket(
86-
"llm-fork", // forkname
86+
"llm-fork", // name of the fork bucket being created
8787
{
88-
sourceBucketName: "llm-base", // source bucket name
88+
sourceBucketName: "llm-base", // name of the fork parent bucket
8989
},
9090
);
9191

0 commit comments

Comments
 (0)