百度智能云

All Product Document

          Object Storage

          Simple Download

          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:

          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();
          }
          Previous
          Upload Data
          Next
          Breakpoint Resume Download