com.baidubce.services.bos.model
Class GetObjectRequest

java.lang.Object
  extended by com.baidubce.model.AbstractBceRequest
      extended by com.baidubce.services.bos.model.GenericBucketRequest
          extended by com.baidubce.services.bos.model.GenericObjectRequest
              extended by com.baidubce.services.bos.model.GetObjectRequest

public class GetObjectRequest
extends GenericObjectRequest

Provides options for downloading an Baidu Bos object.

All GetObjectRequests must specify a bucket name and key. Beyond that, requests can also specify:


Constructor Summary
GetObjectRequest()
           
GetObjectRequest(String bucketName, String key)
          Constructs a new GetObjectRequest with all the required parameters.
 
Method Summary
 long[] getRange()
          Gets the optional inclusive byte range within the desired object that will be downloaded by this request.
 void setRange(long start, long end)
          Sets the optional inclusive byte range within the desired object that will be downloaded by this request.
 GetObjectRequest withBucketName(String bucketName)
          Sets the name of the bucket containing the object to be downloaded.
 GetObjectRequest withKey(String key)
          Sets the key under which the object to be downloaded is stored.
 GetObjectRequest withRange(long start, long end)
          Sets the optional inclusive byte range within the desired object that will be downloaded by this request.
 GetObjectRequest withRequestCredentials(BceCredentials credentials)
           
 
Methods inherited from class com.baidubce.services.bos.model.GenericObjectRequest
getKey, setKey
 
Methods inherited from class com.baidubce.services.bos.model.GenericBucketRequest
getBucketName, setBucketName
 
Methods inherited from class com.baidubce.model.AbstractBceRequest
getRequestCredentials, setRequestCredentials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GetObjectRequest

public GetObjectRequest()

GetObjectRequest

public GetObjectRequest(String bucketName,
                        String key)
Constructs a new GetObjectRequest with all the required parameters.

Parameters:
bucketName - The name of the bucket containing the desired object.
key - The key in the specified bucket under which the object is stored.
Method Detail

withRequestCredentials

public GetObjectRequest withRequestCredentials(BceCredentials credentials)
Specified by:
withRequestCredentials in class AbstractBceRequest

withBucketName

public GetObjectRequest withBucketName(String bucketName)
Sets the name of the bucket containing the object to be downloaded. Returns this GetObjectRequest, enabling additional method calls to be chained together.

Specified by:
withBucketName in class GenericBucketRequest
Parameters:
bucketName - The name of the bucket containing the object to be downloaded.
Returns:
This GetObjectRequest, enabling additional method calls to be chained together.

withKey

public GetObjectRequest withKey(String key)
Sets the key under which the object to be downloaded is stored. Returns this GetObjectRequest, enabling additional method calls to be chained together.

Specified by:
withKey in class GenericObjectRequest
Parameters:
key - The key under which the object to be downloaded is stored.
Returns:
This GetObjectRequest, enabling additional method calls to be chained together.

getRange

public long[] getRange()
Gets the optional inclusive byte range within the desired object that will be downloaded by this request.

The range is returned as a two element array, containing the start and end index of the byte range. If no byte range has been specified, the entire object is downloaded and this method returns null.

Returns:
A two element array indicating the inclusive start index and end index within the object being downloaded by this request. Returns null if no range has been specified, and the whole object is to be downloaded.

setRange

public void setRange(long start,
                     long end)
Sets the optional inclusive byte range within the desired object that will be downloaded by this request.

The first byte in an object has position 0; as an example, the first ten bytes of an object can be downloaded by specifying a range of 0 to 9.

If no byte range is specified, this request downloads the entire object from Baidu Bos.

Parameters:
start - The start of the inclusive byte range to download.
end - The end of the inclusive byte range to download.

withRange

public GetObjectRequest withRange(long start,
                                  long end)
Sets the optional inclusive byte range within the desired object that will be downloaded by this request. Returns this GetObjectRequest, enabling additional method calls to be chained together.

The first byte in an object has position 0; as an example, the first ten bytes of an object can be downloaded by specifying a range of 0 to 9.

If no byte range is specified, this request downloads the entire object from Baidu Bos.

Parameters:
start - The start of the inclusive byte range to download.
end - The end of the inclusive byte range to download.
Returns:
This GetObjectRequest, enabling additional method calls to be chained together.


Copyright © 2018. All rights reserved.