Install
openclaw skills install aliyun-oss-2Aliyun OSS (Object Storage Service) file management toolkit for Python. Use when working with Aliyun OSS to upload files, download files, list objects, delete files, manage directories, read file contents, check file existence, get file metadata, copy and move objects. Supports both authenticated (with API key/secret for write operations) and anonymous access (read-only).
openclaw skills install aliyun-oss-2pywayne.aliyun_oss.OssManager provides a comprehensive toolkit for managing Aliyun OSS (Object Storage Service) buckets.
from pywayne.aliyun_oss import OssManager
# Initialize with write permissions
oss = OssManager(
endpoint="https://oss-cn-xxx.aliyuncs.com",
bucket_name="my-bucket",
api_key="your_api_key",
api_secret="your_api_secret"
)
# Initialize with read-only (anonymous) access
oss = OssManager(
endpoint="https://oss-cn-xxx.aliyuncs.com",
bucket_name="my-bucket",
verbose=False # Disable verbose output
)
oss.upload_file(key="data/sample.txt", file_path="./sample.txt")
oss.upload_text(key="config/settings.json", text='{"key": "value"}')
import cv2
image = cv2.imread("photo.jpg")
oss.upload_image(key="photos/photo.jpg", image=image)
oss.upload_directory(local_path="./local_folder", prefix="remote_folder/")
# Preserve directory structure: downloads/data/sample.txt
oss.download_file(key="data/sample.txt", root_dir="./downloads")
# Use only basename: downloads/sample.txt
oss.download_file(key="data/sample.txt", root_dir="./downloads", use_basename=True)
oss.download_files_with_prefix(prefix="photos/", root_dir="./downloads")
oss.download_directory(prefix="photos/", local_path="./downloads")
keys = oss.list_all_keys() # Returns sorted list
keys = oss.list_keys_with_prefix(prefix="data/")
contents = oss.list_directory_contents(prefix="data/")
# Returns: [("file1.txt", False), ("subdir", True), ...]
content = oss.read_file_content(key="config/settings.json")
if oss.key_exists("data/sample.txt"):
print("File exists")
metadata = oss.get_file_metadata("data/sample.txt")
# Returns: {'content_length': 1234, 'last_modified': ..., 'etag': ..., 'content_type': ...}
oss.delete_file(key="data/sample.txt")
oss.delete_files_with_prefix(prefix="temp/")
oss.copy_object(source_key="data/original.txt", target_key="backup/original.txt")
oss.move_object(source_key="data/temp.txt", target_key="archive/temp.txt")
api_key and api_secretapi_key and api_secret for read-only access/)list_all_keys() and list_keys_with_prefix() use natural sorting by defaultverbose=True (default)