Simple Download
Updated at:2025-11-03
Overview
A simple download refers to retrieving an already uploaded file (object) through the GetObject API of the BOS API. The download is performed using an HTTP GET request, and the user must have read permissions for the bucket where the object resides.
Operation types
BOS supports downloading objects using both APIs and SDKs, with the specific methods as follows:
-
Obtaining an object using the API:
-
Obtain an object using SDK:
- Java SDK
- [Python SDK](BOS/SDK/Python-SDK/File management/Download file.md)
- PHP SDK
- C# SDK
- Android SDK
Example
The following is a code example using the Java SDK, which can simply download an object:
Plain Text
1public void getObject(BosClient client, String bucketName, String objectKey)
2 throws IOException {
3 //Obtain the object, with returned result BosObject object
4 BosObject object = client.getObject(bucketName, objectKey);
5 // Retrieve ObjectMeta
6 ObjectMetadata meta = object.getObjectMetadata();
7 //Obtain the object's input stream
8 InputStream objectContent = object.getObjectContent();
9 // Process object
10 ...
11 // Close stream
12 objectContent.close();
13}
