Skip to content
Console

Move and rename objects

Traditional object storage services (Tencent COS, Aliyun OSS, AWS S3) don't support a native Move operation. To rename an object, you have to copy it and then delete the original, which is expensive.

Bitiful S4 supports a native Move operation, letting you move or rename files efficiently.

Copy + deleteS4 Move
DataA full copy is madeNo copy; only the location changes
TimeGrows with file sizeIndependent of file size
Intermediate stateBoth copies may exist at once, or it may fail midwayNone; it either succeeds or nothing changes
MetadataDepends on the implementationUnchanged; the modification time is updated

In the console

In File management (文件管理), click … › Move (rename) (移动 (重命名)) on the right of the file, edit the full path, and confirm. For the rules, see Manage files.

With the S3 API

Call the standard CopyObject and append ?move=true to the copy source:

PUT /new/photo.jpg HTTP/1.1
Host: my-bucket.s3.bitiful.net
x-amz-copy-source: /my-bucket/old/photo.jpg?move=true

?deleteAfterCopy=true has the same effect as ?move=true. On success, S4 returns 200 and a CopyObjectResult, and the old object no longer exists.

The examples below move old/照片 1.jpg to new/photo.jpg. Except for Python and the AWS CLI, which encode automatically, you need to URL-encode the source path yourself in other languages.

aws s3api copy-object \
  --bucket my-bucket \
  --key "new/photo.jpg" \
  --copy-source "my-bucket/old/照片 1.jpg?move=true" \
  --endpoint-url https://s3.bitiful.net --region cn-east-1

Avoid overwriting

If the destination already exists, it is overwritten by default. Add a conditional header to prevent this:

HeaderEffect
If-None-Match: *Moves only if the destination doesn't exist; otherwise returns 412
If-Match: "<ETag>"Overwrites only if the destination is still the specified version
x-amz-copy-source-if-match: "<ETag>"Moves only if the source object is still the specified version
aws s3api copy-object \
  --bucket my-bucket --key "new/photo.jpg" \
  --copy-source "my-bucket/old/photo.jpg?move=true" \
  --if-none-match "*" \
  --endpoint-url https://s3.bitiful.net --region cn-east-1

--if-none-match requires a recent version of the AWS CLI. For the full details of conditional headers, see Conditional requests.

Move an entire directory

There is no API for moving a directory. List the objects in the directory and move them one by one:

move_dir.py
def move_dir(bucket: str, src_dir: str, dst_dir: str) -> None:
    # Reuses s3 and move from above; list everything first, then move, to avoid changing keys while listing
    keys = []
    for page in s3.get_paginator("list_objects_v2").paginate(Bucket=bucket, Prefix=src_dir):
        keys += [o["Key"] for o in page.get("Contents", []) if not o["Key"].endswith("/")]
    for key in keys:
        move(bucket, key, dst_dir + key[len(src_dir):])


move_dir("my-bucket", "old/", "archive/2026/")

Permissions and limits

ItemDescription
PermissionsRead and write permissions on the source object, and write permission on the destination. See Sub-user permissions
ScopeThe source and destination must be in the same bucket
Object typeFiles only; directory objects aren't supported
Changing metadataYou can't change metadata such as Content-Type during a move, and MetadataDirective has no effect. To change metadata, make a separate CopyObject call
Destination pathThe destination path can't start with the full key of the source object. For example, you can't move photo to photo-2026/1.jpg
Source pathObjects whose keys contain ? can't be moved this way, because everything after ? is treated as parameters
Not applicableMultipart copy (UploadPartCopy) doesn't support move=true

Error codes

Status codeError codeCause
400InvalidArgumentThe source object doesn't exist, or it is a directory
400InvalidCopyDestThe source and destination are the same
400InvalidMoveDestA cross-bucket move, or the destination path violates the limits above
403AccessDeniedMissing read and write permissions on the source or write permission on the destination
409OperationAbortedConflicts with a concurrent write; retry later
412PreconditionFailedA conditional header isn't satisfied