• Object Storage Service

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

Performing a File-Based 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 ***',    

resp = obsClient.getObject('bucketname', 'objectkey', downloadPath='localfile')
if resp.status < 300:
    print('requestId:', resp.requestId)
    print('url:', resp.body.url)
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
  • Use the downloadPath parameter to set the save path for the file to be downloaded.
  • When loadStreamInMemory is set to True, the downloadPath parameter is ineffective.