☁️ Oss API Reference
February 11, 2026 · View on GitHub
Overview
The Oss module provides specialized functionality for the AgentBay cloud platform. It includes various methods and utilities to interact with cloud services and manage resources.
📚 Tutorial
Integrate with Alibaba Cloud OSS for file storage
OSS
Handles Object Storage Service operations in the AgentBay cloud environment.
Constructor
public OSS(Session session)
Initialize an OSS object.
Parameters:
session(Session): The Session instance that this OSS belongs to
Methods
envInit
public OSSClientResult envInit(String accessKeyId, String accessKeySecret, String securityToken, String endpoint, String region)
Create an OSS client with the provided STS temporary credentials.
Parameters:
accessKeyId(String): The Access Key ID from STS temporary credentials.accessKeySecret(String): The Access Key Secret from STS temporary credentials.securityToken(String): Security token from STS temporary credentials. Required for security.endpoint(String): The OSS service endpoint. If not specified, the default is used.region(String): The OSS region. If not specified, the default is used.
Returns:
OSSClientResult: OSSClientResult containing client configuration and error message if any.
upload
public OSSUploadResult upload(String bucket, String object, String path)
Upload a local file or directory to OSS.
Note: Before calling this API, you must first call envInit to initialize the OSS environment.
Parameters:
bucket(String): OSS bucket name.object(String): Object key in OSS.path(String): Local file or directory path to upload.
Returns:
OSSUploadResult: OSSUploadResult containing upload result and error message if any.
uploadAnonymous
public OSSUploadResult uploadAnonymous(String url, String path)
Upload a local file or directory to a URL anonymously.
Parameters:
url(String): The HTTP/HTTPS URL to upload the file to.path(String): Local file or directory path to upload.
Returns:
OSSUploadResult: OSSUploadResult containing upload result and error message if any.
download
public OSSDownloadResult download(String bucket, String object, String path)
Download an object from OSS to a local file or directory.
Note: Before calling this API, you must first call envInit to initialize the OSS environment.
Parameters:
bucket(String): OSS bucket name.object(String): Object key in OSS.path(String): Local file or directory path to download to.
Returns:
OSSDownloadResult: OSSDownloadResult containing download status and error message if any.
downloadAnonymous
public OSSDownloadResult downloadAnonymous(String url, String path)
Download a file from a URL anonymously to a local file path.
Parameters:
url(String): The HTTP/HTTPS URL to download the file from.path(String): Local file or directory path to download to.
Returns:
OSSDownloadResult: OSSDownloadResult containing download status and error message if any.
uploadFile
public OSSUploadResult uploadFile(String localPath, String remotePath) throws OSSException
downloadFile
public OSSDownloadResult downloadFile(String remotePath, String localPath) throws OSSException
deleteFile
public DeleteResult deleteFile(String remotePath) throws OSSException
getClient
public OSSClientResult getClient()
uploadLegacy
public OSSUploadResult uploadLegacy(String localPath, String remotePath, String bucketName) throws OSSException
uploadAnonymousLegacy
public OSSUploadResult uploadAnonymousLegacy(String localPath, String remotePath) throws OSSException
downloadLegacy
public OSSDownloadResult downloadLegacy(String remotePath, String localPath, String bucketName) throws OSSException
deleteFileVoid
public void deleteFileVoid(String remotePath) throws OSSException