feat: add docs for buckets s3 compatibility api#2586
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
|
||
| The gateway is currently single-region. To improve download performance, `GetObject` typically responds with an HTTP 302 redirect to the nearest Hugging Face CDN edge rather than serving bytes directly. | ||
|
|
||
| Some SDKs don't follow redirects from an S3 endpoint, so the gateway detects clients identifying as `aws-cli`, `botocore` (which covers `boto3`), or `aws-sdk-rust` and proxies the data through itself for them. All other clients (`rclone`, `s5cmd`, `curl`, the AWS Go SDK, etc.) receive the 302 and follow it natively, keeping the gateway out of the data path for faster downloads. |
There was a problem hiding this comment.
proxies the data through itself
ouch, this sounds costly 😓
There was a problem hiding this comment.
Yeah, it is unfortunate that the aws-cli/boto libraries don't follow redirects. We might want to think about integrating this API with the Hugging Face CDN if we find that a significant amount of downloads are being proxied.
|
We need to link to this doc in moon-landing when we create the S3 secrets I guess. |
Wauplin
left a comment
There was a problem hiding this comment.
Very nice!
Wondering if we should add a real use case example already or if that should rather live in a separate doc. Here is a CC suggestion on how to import data using rclone:
## Example: import data using `rclone`
[`rclone`](https://rclone.org/) is a convenient way to copy data between two S3-compatible stores, so it's a good fit for moving an existing AWS S3 bucket (or any S3-compatible source) into a Storage Bucket.
The idea is to declare two remotes — your source bucket and the Hugging Face gateway — and let `rclone` stream the objects between them. Add both remotes to `~/.config/rclone/rclone.conf`. The first points at your existing S3 bucket; adjust it to match your source (here, plain AWS S3):
```ini
[aws]
type = s3
provider = AWS
access_key_id = AKIA...
secret_access_key = ...
region = us-east-1
```
The second points at the Hugging Face gateway. As with any other client, scope the endpoint to your [namespace](#addressing-buckets), use `path` addressing, and set large multipart sizes so uploads use as few parts as possible:
```ini
[hf]
type = s3
provider = Other
endpoint = https://s3.hf.co/<namespace>
access_key_id = HFAK...
secret_access_key = ...
region = us-east-1
force_path_style = true
upload_cutoff = 2G
chunk_size = 2G
```
Note: replace the `<namespace>` above with the username or organization your buckets are stored in, and use the [S3 credentials](#generating-s3-credentials) generated from your access token. The destination bucket must already exists under that namespace.
Now, let's copy a source bucket into your Storage Bucket using `rclone`:
```bash
rclone copy aws:my-source-bucket hf:my-bucket --progress
```
`rclone copy` only transfers objects that are missing or changed at the destination, so it's safe to re-run to resume an interrupted import or pick up new objects. To make the destination an exact mirror of the source — deleting objects at the destination that no longer exist at the source — use `rclone sync` instead:
```bash
rclone sync aws:my-source-bucket hf:my-bucket --progress
```
> [!TIP]
> For large imports, add `--transfers` and `--checkers` to raise the concurrency (e.g. `--transfers 16 --checkers 16`), and run `rclone check aws:my-source-bucket hf:my-bucket` afterwards to confirm every object made it across.
(can be done in a future PR)
|
@Wauplin Yes, I was wondering about that as well. |
Had Claude Code run a bunch of S3 tooling and it found that the So the [hf]
type = s3
provider = Other
endpoint = https://s3.hf.co/<namespace>
access_key_id = HFAK...
secret_access_key = ...
region = us-east-1
force_path_style = true
upload_cutoff = 2G
chunk_size = 2G
list_version = 2 |
| | **CLI sync** | Batch transfers, backups | [Sync docs](./storage-buckets#syncing-directories) | | ||
|
|
||
| Access through the S3 API is not currently supported, but is on the roadmap. | ||
| | **S3 API** | Existing S3 tooling (AWS CLI, boto3, s5cmd) | [S3-Compatible API](./storage-buckets-s3) | |
Yeah, I agree that is a good idea. I've added an |
Storage Buckets now expose an S3-compatible API via a gateway at https://s3.hf.co, so users can reach their buckets with existing S3 tooling (AWS CLI, boto3, s5cmd, etc.).
This PR documents that feature and its limitations/differences to AWS S3 in a new
Storage Buckets -> S3 Compatibilitypage.Note
Low Risk
Documentation-only changes with no runtime, auth, or data-handling code modifications.
Overview
Documents the S3-compatible gateway (
https://s3.hf.co) for Storage Buckets so users can use AWS CLI,boto3,s5cmd, and similar tools without rewriting workflows.Adds a new S3 Compatibility Hub doc page covering credential generation from access tokens, required client settings (path-style addressing,
us-east-1, checksum workarounds for newer AWS clients), namespace/bucket addressing patterns, AWS S3 differences/limitations, and anrcloneimport example. The Storage Buckets section in_toctree.ymlnow links this page; Access Patterns lists S3 API as an option (replacing the prior “not supported” note), and the main Storage Buckets tip points readers to the new guide.Reviewed by Cursor Bugbot for commit b858ad3. Bugbot is set up for automated code reviews on this repo. Configure here.