• Object Storage Service

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

Performing a File-Based Upload

File-based upload uses local files as data sources. You can call ObsClient.putFile to upload a local file. Sample code is as follows:

# 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.putFile('bucketname', 'objectkey', file_path='localfile')

if resp.status < 300:    
    print('requestId:', resp.requestId)
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)