本文主要介绍如何使用OSS的Python SDK去获取private Bucket的图片处理服务。图片处理服务都是GET操作,使用OSS的Python SDK时主要以Get Object为主,传入的参数一般是Bucket、Object。

OSS的Python SDK代码示例

获取bucket: image-demo,object: example.jpg

bucket = 'image-demo'
object = 'example.jpg'
self.oss.get_object(bucket,object)

图片服务

  • 简单缩略

    获取bucket: image-demo,object: example.jpg

    转换字符:100w_100h.jpg

    bucket = 'image-demo'
    object = 'example.jpg'
    query = '100w_100h.jpg'
    object = object + '@' + query 
    self.oss.get_object(bucket, object)
  • 图片水印

    获取bucket: image-demo,object: example.jpg

    转换字符:watermark=1&object=cGFuZGEucG5n&t=90&p=5

    bucket = 'image-demo'
    object = 'example.jpg'
    query = ' watermark=2&text=SGVsbG8g5Zu-54mH5pyN5YqhIQ '
    object = object + '@' + query 
    self.oss.get_object(bucket, object)
  • 样式

    获取bucket: image-demo, object:example.jpg

    样式名:pipe1

    bucket = 'image-demo'
    object = 'example.jpg'
    style = ' pipe1 '
    object = object + '@!' + style
    self.oss.get_object(bucket, object)
  • 管道

    获取bucket: image-demo, object:example.jpg

    管道操作: 200w.jpg|watermark=1&object=cGFuZGEucG5n&t=90&p=5
    bucket = 'image-demo'
    object = 'example.jpg'
    query = ' 200w.jpg|watermark=1&object=cGFuZGEucG5n&t=90&p=5'
    object = object + '@' + query
    self.oss.get_object(bucket, object)