# S3 API compatibility

> Which S3 API operations Bitiful S4 supports, plus signatures and checksums, object key rules, size limits, and how directory buckets differ from standard S3.

Bitiful S4 is compatible with the S3 protocol, so mainstream SDKs and tools work after you change the endpoint. This page lists the actual support status of each API operation and where S4 differs from standard S3.

## Connection details

| Item                         | Value                                                                                |
| ---------------------------- | ------------------------------------------------------------------------------------ |
| Endpoint                     | `https://s3.bitiful.net`                                                             |
| Region                       | `cn-east-1`                                                                          |
| Virtual-hosted-style address | `https://<bucket-name>.s3.bitiful.net/<object-key>` (recommended)                    |
| Path-style address           | `https://s3.bitiful.net/<bucket-name>/<object-key>`                                  |
| Credentials                  | Sub-user [AccessKey](https://docs.bitiful.com/en/bitiful-s4/handbook/access-keys.md) |

Both address styles work. Use the SDK's default virtual-hosted style; you do not need to force path style.

## Support status

| Label               | Meaning                                                  |
| ------------------- | -------------------------------------------------------- |
| Supported           | Behaves like S3; differences are noted in the notes      |
| Partially supported | Works, but with clear limitations                        |
| No effect           | The request succeeds but does nothing. Do not rely on it |
| Not supported       | Returns an error, or is not implemented                  |

> **Warning**
>
> Operations marked "No effect" are kept so client tools do not report errors, for example object lock. A successful call **does not mean** your data is protected.

## Object operations

| Operation                                                 | Status                | Notes                                                                                                                                                                                                                          |
| --------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| GetObject                                                 | Supported             | Supports Range, conditional reads, and `response-*` override parameters. Ignores `versionId` and `partNumber`                                                                                                                  |
| HeadObject                                                | Supported             | Same as above                                                                                                                                                                                                                  |
| PutObject                                                 | Supported             | Supports conditional writes, user metadata, tags, and Content-MD5                                                                                                                                                              |
| DeleteObject                                              | Supported             | Returns 204 even if the object does not exist; returns 500 if the deletion fails on the server, and you can retry. Supports conditional deletion with `If-Match`. Ignores `versionId`                                          |
| DeleteObjects                                             | Supported             | Up to 1000 keys at a time. If you lack write permission on any one key, the whole batch returns 403                                                                                                                            |
| CopyObject                                                | Supported             | Supports `REPLACE` for metadata and tags, and source and destination conditions. Self-copy differs; see [below](https://docs.bitiful.com/bitiful-s4/intro.md#change-metadata-with-self-copy). The source must be a file object |
| Move / rename                                             | Supported (extension) | Append `?move=true` to the value of `x-amz-copy-source`. See [Move and rename objects](https://docs.bitiful.com/en/bitiful-s4/features/move-object.md)                                                                         |
| PostObject (form upload)                                  | Supported             | Supports policy, `success_action_status`, `success_action_redirect`, and `content-length-range`. Conditional writes are not supported                                                                                          |
| GetObjectTagging / PutObjectTagging / DeleteObjectTagging | Supported             | Up to 10 tags; keys up to 128 bytes, values up to 256 bytes                                                                                                                                                                    |
| SelectObjectContent                                       | Supported             |                                                                                                                                                                                                                                |
| GetObjectAcl / PutObjectAcl                               | No effect             | Returns 204. Set permissions in the console using [sub-users](https://docs.bitiful.com/en/bitiful-s4/handbook/permissions.md) or [public read](https://docs.bitiful.com/en/bitiful-s4/handbook/public-read.md)                 |
| PutObjectRetention / PutObjectLegalHold                   | No effect             | Returns 204; the object is not locked                                                                                                                                                                                          |
| GetObjectRetention / GetObjectLegalHold                   | Not supported         |                                                                                                                                                                                                                                |
| GetObjectAttributes                                       | Not supported         | Use HeadObject                                                                                                                                                                                                                 |
| RestoreObject, GetObjectTorrent                           | Not supported         |                                                                                                                                                                                                                                |
| RenameObject                                              | Not supported         | Use the move extension                                                                                                                                                                                                         |

The `x-amz-acl`, `x-amz-server-side-encryption*`, and `x-amz-object-lock-*` headers are accepted but have no effect. `x-amz-storage-class` is saved and returned in listings, but it does not affect how data is stored or priced.

## Multipart uploads

| Operation               | Status              | Notes                                                                                                   |
| ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------- |
| CreateMultipartUpload   | Supported           | Can carry conditional headers; the conditions are kept and evaluated at Complete                        |
| UploadPart              | Supported           | Ignores conditional headers                                                                             |
| UploadPartCopy          | Supported           | Supports `x-amz-copy-source-range` and source conditions                                                |
| CompleteMultipartUpload | Supported           | Supports conditional writes. You can submit only some of the parts; parts you do not list are discarded |
| AbortMultipartUpload    | Supported           | Does not affect an existing object with the same name                                                   |
| ListParts               | Supported           | Paginates with `max-parts` and `part-number-marker`                                                     |
| ListMultipartUploads    | Partially supported | Supports `prefix`, `max-uploads`, and `upload-id-marker`. `delimiter` grouping is not supported         |

- Part numbers range from 1 to 10000. Every part except the last must be at least 5 MiB, or the request returns `EntityTooSmall`.
- At Complete, each part must carry the ETag returned by UploadPart; a mismatch returns `InvalidPart`.
- If all parts are 0 bytes, the request returns `InvalidPart`. Use PutObject directly for empty files.
- A failed Complete does not delete the uploaded parts; you can fix the request and retry.
- Incomplete parts are retained indefinitely. Call AbortMultipartUpload when you no longer need them.
- The ETag of a multipart upload looks like `<md5>-<part-count>` and does not equal the file's MD5.

## Bucket operations

| Operation                                        | Status              | Notes                                                                                                                                                                                                                                                                             |
| ------------------------------------------------ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ListBuckets                                      | Supported           | Returns only the buckets the current sub-user has been granted access to                                                                                                                                                                                                          |
| HeadBucket, GetBucketLocation                    | Supported           | Location is always `cn-east-1`                                                                                                                                                                                                                                                    |
| ListObjectsV2                                    | Supported           | See [List objects](https://docs.bitiful.com/bitiful-s4/intro.md#list-objects)                                                                                                                                                                                                     |
| ListObjects (V1)                                 | Supported           | V2 is recommended                                                                                                                                                                                                                                                                 |
| CreateBucket                                     | Partially supported | Sub-users cannot create buckets; create them in the [console](https://docs.bitiful.com/en/bitiful-s4/handbook/buckets.md). If the bucket already exists and belongs to you, it returns 409 `BucketAlreadyOwnedByYou`, which keeps tools that create buckets automatically working |
| DeleteBucket                                     | Partially supported | Sub-users cannot delete buckets; delete them in the console                                                                                                                                                                                                                       |
| GetBucketCors / PutBucketCors / DeleteBucketCors | Supported           | Requires write permission on the bucket; up to 10 rules. With no rules, Get returns an empty configuration instead of 404. You can also configure this in the [console](https://docs.bitiful.com/en/bitiful-s4/handbook/cors.md)                                                  |
| GetBucketAcl                                     | Partially supported | The response does not reflect sub-user grants; do not use it to determine permissions                                                                                                                                                                                             |
| PutBucketAcl                                     | Not supported       | 501 `NotImplemented`                                                                                                                                                                                                                                                              |
| GetBucketPolicy                                  | Partially supported | Always returns 404 `NoSuchBucketPolicy`                                                                                                                                                                                                                                           |
| PutBucketPolicy, DeleteBucketPolicy              | Not supported       | Put returns 501                                                                                                                                                                                                                                                                   |
| GetBucketVersioning                              | Partially supported | Always returns not enabled                                                                                                                                                                                                                                                        |
| PutBucketVersioning                              | Not supported       | 501                                                                                                                                                                                                                                                                               |
| ListObjectVersions                               | Not supported       |                                                                                                                                                                                                                                                                                   |
| GetBucketLifecycleConfiguration                  | Partially supported | With no rules, returns 404 `NoSuchLifecycleConfiguration`                                                                                                                                                                                                                         |
| PutBucketLifecycleConfiguration                  | Not supported       | 501                                                                                                                                                                                                                                                                               |
| DeleteBucketLifecycle                            | No effect           | Returns 204                                                                                                                                                                                                                                                                       |
| GetObjectLockConfiguration                       | Partially supported | Always returns not enabled                                                                                                                                                                                                                                                        |
| PutObjectLockConfiguration                       | Not supported       | 501                                                                                                                                                                                                                                                                               |
| GetBucketRequestPayment                          | Partially supported | Always returns `BucketOwner`                                                                                                                                                                                                                                                      |

None of the following bucket-level features are implemented: encryption, tagging, logging, static website, event notifications, replication, Block Public Access (PublicAccessBlock), ownership controls, transfer acceleration, inventory, analytics, metrics, and intelligent tiering.

> **Warning**
>
> Do not send requests for subresources that are not listed (for example `?encryption`, `?tagging`, or `?website`). S4 ignores query parameters it does not recognize and handles the request as an ordinary listing, bucket creation, or bucket deletion request, so a successful response does not mean the configuration exists.

Static websites, mirror back-to-origin, hotlink protection, and similar features are configured in the console. See [Static websites and domains](https://docs.bitiful.com/en/bitiful-s4/handbook/website.md), [Mirror back-to-origin](https://docs.bitiful.com/en/bitiful-s4/handbook/mirror.md), and [Access control](https://docs.bitiful.com/en/bitiful-s4/handbook/anti-leech.md).

## List objects

| Parameter            | Notes                                                                                                          |
| -------------------- | -------------------------------------------------------------------------------------------------------------- |
| `max-keys`           | Defaults to **100** (standard S3 defaults to 1000); the maximum is 1000, and larger values are treated as 1000 |
| `prefix`             | Supported                                                                                                      |
| `delimiter`          | Only `/` is supported; other values return 501 `NotImplemented`                                                |
| `continuation-token` | Use the `NextContinuationToken` returned by the previous page                                                  |
| `start-after`        | Supported                                                                                                      |
| `encoding-type`      | Supports `url`                                                                                                 |
| `fetch-owner`        | Ignored; Owner is always returned                                                                              |

- Paginate based on `IsTruncated` and `NextContinuationToken`; do not assume each page has 1000 entries.
- Do not rely on strict lexicographic order. Listing proceeds by directory level, so the order with and without a delimiter can differ.
- If a sub-user has only directory-level listing permission, the results are narrowed automatically to the authorized directories.
- Returned entries include the extra `Mime` and `Metadata` fields compared with standard S3; SDKs ignore them.

## Signatures

| Method                                | Status                                                                                                   |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Signature V4 (`Authorization` header) | Supported, recommended                                                                                   |
| Signature V4 presigned URL            | Supported, up to 7 days. See [Presigned URLs](https://docs.bitiful.com/en/developer/s3/presigned-url.md) |
| Signature V4 POST policy              | Supported                                                                                                |
| Signature V2 (header and presigned)   | Supported; recommended only for legacy clients                                                           |
| STS temporary credentials             | Not supported                                                                                            |

Requests whose time differs from the server time by more than 15 minutes are rejected.

All `x-amz-*` headers in a request must be signed, or the request returns 403 `AccessDenied` with the message `There were headers present in the request which were not signed`. The exceptions are `x-amz-content-sha256` and `x-amz-date`, and headers whose value is identical to a query parameter of the same name in the URL. SDKs handle this automatically; watch for it when you sign requests by hand or create presigned uploads.

### Payload signing forms

`x-amz-content-sha256` accepts the following values:

| Value                                        | Notes                                                                                                                                     |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| SHA-256 of the content                       | Regular signing. S4 verifies the actual content; a mismatch returns 400 `XAmzContentSHA256Mismatch` and the existing object is unaffected |
| `UNSIGNED-PAYLOAD`                           | The content is not signed                                                                                                                 |
| `STREAMING-AWS4-HMAC-SHA256-PAYLOAD`         | Chunked signing                                                                                                                           |
| `STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER` | Chunked signing with a checksum trailer                                                                                                   |
| `STREAMING-UNSIGNED-PAYLOAD-TRAILER`         | Unsigned content with a checksum trailer. The default for recent SDKs over HTTPS                                                          |

Chunked forms are used only for PutObject and UploadPart, and cannot be combined with presigned URLs. Recent SDKs do not require you to disable Payload Signing or default checksums.

## Integrity checks

| Method                                       | Notes                                                                                                                 |
| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `Content-MD5`                                | Verified before writing; a mismatch returns 400 `BadDigest` and the existing object is unaffected                     |
| Trailer checksum                             | Supports `CRC32`, `CRC32C`, `CRC64NVME`, `SHA1`, and `SHA256`; a mismatch returns `BadDigest`                         |
| `x-amz-content-sha256`                       | When the value is a content digest, it is verified before writing; a mismatch returns 400 `XAmzContentSHA256Mismatch` |
| `x-amz-checksum-*` in request headers        | Accepted but not verified                                                                                             |
| Checksums returned by GetObject / HeadObject | Not supported; `x-amz-checksum-mode` is ignored                                                                       |

For end-to-end verification, use regular signing (content SHA-256), `Content-MD5`, or a trailer checksum. The ETag of a regular PutObject is the MD5 of the content, so you can use it to cross-check as well.

## Sizes and counts

| Item             | Limit                                         |
| ---------------- | --------------------------------------------- |
| Single PutObject | 20 GiB                                        |
| Single part      | 5 MiB to 20 GiB; the last part can be smaller |
| Number of parts  | 10000                                         |
| Batch delete     | 1000 per request                              |
| Listing          | 1000 per page                                 |

For limits on QPS, bandwidth, number of buckets, and so on, see [Limits](https://docs.bitiful.com/en/bitiful-s4/limits.md).

## Object key rules

For naming conventions, see [Key terms and concepts](https://docs.bitiful.com/en/bitiful-s4/definitions.md). The following points are easy to get wrong: A key can be at most 1024 bytes after UTF-8 encoding; longer keys return 400 `KeyTooLongError`.

| Case                                                      | How S4 handles it                                                                                                                                                                                                 |
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Non-printable characters                                  | Rejected with 400. Besides control characters, the full-width space (U+3000) and zero-width characters count as non-printable, and some combined emoji are also rejected because they contain a zero-width joiner |
| Regular spaces                                            | Supported                                                                                                                                                                                                         |
| A whole segment that is `.` or `..`, for example `a/../b` | Rejected. Names such as `a..b` are not affected                                                                                                                                                                   |
| Consecutive slashes, for example `a//b`                   | Merged into one; equivalent to `a/b`                                                                                                                                                                              |
| Leading slash                                             | Removed; `/a` is equivalent to `a`                                                                                                                                                                                |
| `%` in a key                                              | Decoded only once. Writing `%2520` in the URL means `%20` in the key                                                                                                                                              |
| Case                                                      | Sensitive                                                                                                                                                                                                         |

## Differences between directory buckets and standard S3

All S4 buckets are directory buckets, and paths are organized as real directories. Compared with the flat structure of standard S3, the differences are as follows.

### A file and a directory cannot share a name

| Operation                                                 | Result                                                                                                        |
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `a/b.txt` exists, then you write a file `a`               | 409 `ExistingObjectIsDirectory`. The same applies to PutObject, CopyObject, and completing a multipart upload |
| File `a` exists, then you write `a/b.txt`                 | 409 `ExistingObjectIsFile`                                                                                    |
| File `a` exists, then you create directory `a/` or `a/b/` | 409 `ExistingObjectIsFile`                                                                                    |

A rejected write does not change existing content. After all objects under a directory are deleted (and no directory object was created), you can write a file with the same name. When the condition of a conditional request does not hold, 412 is returned first. Type conflicts in a move return 400. See [Move objects](https://docs.bitiful.com/en/bitiful-s4/features/move-object.md).

### Directory objects

- A key ending in `/` is a directory object, for example `photos/`. PutObject creates the directory and ignores the request body.
- GET `photos/` returns 200 with empty content. GET `photos` (without the slash) returns 404.
- Writing `photos/a.jpg` creates the parent directories automatically. Automatically created directories are not objects and do not appear in listings without a delimiter.
- Deleting a non-empty directory object returns success, but the files inside are not affected. To delete an entire directory, do it in the console. See [Manage files](https://docs.bitiful.com/en/bitiful-s4/handbook/objects.md).

### Change metadata with self-copy

Copying an object onto itself with `x-amz-metadata-directive: REPLACE` changes its metadata without re-uploading:

- `x-amz-meta-*`, `Cache-Control`, `Content-Disposition`, and `Expires` follow the request, and anything you don't send is cleared.
- `Content-Type` follows the request. If you don't send it, the original value is kept (standard S3 changes it to `binary/octet-stream`).

### Content-Disposition on download

When you download directly through `*.s3.bitiful.net`, the response `Content-Disposition` is always `attachment`, so the browser downloads the file instead of previewing it. Setting it to `inline` is changed to `attachment`, and the file name is kept. To open files directly in the browser, use a [CDN](https://docs.bitiful.com/en/cdn/intro.md) domain.

`.apk` and `.ipa` files cannot be downloaded directly through S4; the request returns 403 `FileTypeForbidden`, so use the CDN. Uploads and HEAD are not affected.
