• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Object Download
  5. Performing a Binary Download

Performing a Binary Download

Sample code:

# Import the module.
from com.obs.client.obs_client import ObsClient
  
# Create an instance of ObsClient.
obsClient = ObsClient(
    access_key_id='*** Provide your Access Key ***',    
    secret_access_key='*** Provide your Secret Key ***',    
    server='yourdomainname'
)

resp = obsClient.getObject('bucketname', 'objectkey', loadStreamInMemory=True)
if resp.status < 300:
    print('requestId:', resp.requestId)
    # Obtain the object content.
    print('buffer:', resp.body.buffer)
    print('size:',resp.body.size)
else:
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
NOTE:

In a binary download, if loadStreamInMemory is set to True, the object content is contained in the body.buffer field in returned result.