Use S4 with Rclone
Rclone is a command-line sync tool for Windows, macOS, and Linux. It suits bulk uploads, backups, cross-cloud migration, and mounting.
Prerequisites
- You have created a bucket. Sub-users cannot create buckets, and
rclone mkdirreturns 403; - You have created a sub-user and AccessKey and granted it read, write, and list permissions on the bucket.
Install
brew install rclonecurl https://rclone.org/install.sh | sudo bashwinget install Rclone.RcloneConfigure
Run rclone config file to find the configuration file location, and write the following content:
[s4]
type = s3
provider = Other
env_auth = false
access_key_id = Your AccessKey
secret_access_key = Your SecretKey
endpoint = https://s3.bitiful.net
region = cn-east-1
list_version = 2
no_check_bucket = true| Setting | Notes |
|---|---|
endpoint, region | Fixed to the values above |
list_version = 2 | Use ListObjectsV2 |
no_check_bucket = true | Do not check or create the bucket before uploading. Sub-users have no permission to create buckets, so this is required |
Verify the configuration by listing the bucket contents:
rclone lsf s4:my-bucketCommon commands
Upload and download:
# Upload a single file to a directory
rclone copy ./logo.png s4:my-bucket/images/
# Upload a directory, showing progress
rclone copy ./documents s4:my-bucket/documents -P
# Download
rclone copy s4:my-bucket/images/logo.png ./Sync:
# Dry run first, without making any changes
rclone sync ./site s4:my-bucket/site --dry-run
# Make the destination identical to the source; extra files in the destination are deleted
rclone sync ./site s4:my-bucket/site -Psync deletes files in the destination that are not in the source, and S4 has no recycle bin. When in doubt, use copy, or add --dry-run first.
View and verify:
# Count objects and total size
rclone size s4:my-bucket/documents
# Compare local files with the bucket
rclone check ./documents s4:my-bucket/documentsGenerate a temporary download link:
rclone link s4:my-bucket/images/logo.png --expire 1hMany files and large files
# Many small files: increase concurrency
rclone copy ./data s4:my-bucket/data -P --transfers 32 --checkers 32
# Large files: increase the chunk size and per-file concurrency
rclone copy ./video.mp4 s4:my-bucket/videos/ -P \
--s3-chunk-size 64M --s3-upload-concurrency 8Excessive concurrency triggers the QPS limit. When you see 429, lower --transfers, or add --tpslimit 100.
Migrate from other clouds
Add another remote to the configuration file, for example Alibaba Cloud OSS, then copy directly between the two clouds:
rclone copy oss:old-bucket s4:my-bucket -P --transfers 16
rclone check oss:old-bucket s4:my-bucket --size-onlyThe data passes through the machine running Rclone, and the source provider may charge for outbound internet traffic. To migrate without interrupting your service, combine it with mirror back-to-origin.
Mount as a local directory
Linux requires fuse3, macOS requires macFUSE, and Windows requires WinFsp.
mkdir -p ~/s4
rclone mount s4:my-bucket ~/s4 \
--daemon \
--vfs-cache-mode full \
--vfs-cache-max-size 10G \
--vfs-cache-max-age 24h \
--vfs-read-chunk-size 16M \
--vfs-read-chunk-size-limit 256M \
--dir-cache-time 1m \
--log-file ~/rclone.logUnmount:
fusermount3 -u ~/s4 # Linux
umount ~/s4 # macOSMounting suits browsing and sequential reads and writes, but not programs such as databases that need random writes or file locks. Writes go to the local cache first and are uploaded in the background, so make sure uploads have finished before you shut down. For Bitiful's official mounting tool, see Bitifs.
FAQ
403 AccessDenied
Check the sub-user grants. If only a directory is granted, point the path to the granted directory, for example s4:my-bucket/images, and do not operate on the bucket root.
Uploading reports no permission to create the bucket
no_check_bucket = true is missing from the configuration.
Mismatched modification times cause repeated uploads
Use --checksum to compare by size and checksum, or --size-only to compare by size only.