Simple Download
Last Updated:2020-10-23
Basic Introduction
Simple download is to download the uploaded file (object) through the GetObject interface of BOS API. object download is completed by using HTTP GET request. This operation requires the user to have read privilege to the bucket where the object is located.
Operation Method
BOS supports downloading object by using API and SDK tools at the same time, as follows:
-
Use API interface to get object:
-
Use the SDK to get object:
Example
The following is a code example by using the Java SDK, which can simply download object:
public void getObject(BosClient client, String bucketName, String objectKey)
throws IOException {
// Get Object and return BosObject
BosObject object = client.getObject(bucketName, objectKey);
// Get ObjectMeta
ObjectMetadata meta = object.getObjectMetadata();
// Get the input stream of Object
InputStream objectContent = object.getObjectContent();
// Process Object
...
// Close stream
objectContent.close();
}