• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python SDK)
  4. Temporary Authentication
  5. Temporarily Authorized Request

Temporarily Authorized Request

You can call ObsClient.createV2SignedUrl to create a URL for a temporarily authorized request. The following sample code creates a URL for common operations, including bucket creation, as well as object upload, download, listing, and deletion.

# Create a bucket.
res = obsClient.createV2SignedUrl('PUT', 'bucketname', expires= 3600)
print('signedUrl:', res.signedUrl)
print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders)

# Upload an object.
res = obsClient.createV2SignedUrl('PUT', 'bucketname', 'objectkey', expires= 3600, headers={'Content-Type' : 'text/plain'})
print('signedUrl:', res.signedUrl)
print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders)

# Download an object.
res = obsClient.createV2SignedUrl('GET', 'bucketname', 'objectkey', expires= 3600)
print('signedUrl:', res.signedUrl)
print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders)

# List objects.
res = obsClient.createV2SignedUrl('GET', 'bucketname', expires= 3600)
print('signedUrl:', res.signedUrl)
print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders)

# Delete an object.
res = obsClient.createV2SignedUrl('DELETE', 'bucketname', 'objectkey', expires= 3600)
print('signedUrl:', res.signedUrl)
print('actualSignedRequestHeaders:', res.actualSignedRequestHeaders)