By default, Image Processing (IMG) does not save processed images. However, OSS allows you to add the saveas parameter to an IMG request. You can save the processed image as an object to a specified bucket. You can specify the name for the object. Then, you can access the processed image in the specified bucket.

Precautions

  • To perform the saveas operation, you must have permissions to write the target bucket and object.
  • You must call ImgSaveAs to implement the saveas operation. To call this operation, you must have the oss:PostProcessTask permission. For more information, see Create RAM policies.
  • The names of the target bucket and name must comply with the naming conventions of OSS.
  • The target bucket and object must be located within the same region.
  • The saveas operation applies only to the POST request. You cannot perform this operation is the GET request.

Request syntax

POST /ObjectName? x-oss-process HTTP/1.1
Content-Length: ContentLength
Content-Type: ContentType
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
x-oss-process=image/resize,w_100|sys/saveas,o_dGVzdC5qcGc,b_dGVzdA

Use the POST operation to call IMG. Add saveas to an IMG request to save the processed image as an object in OSS. Parameters that follows x-oss-process are used the way you use queryString.to call IMG functions.

Parameters for saveas

Parameter Description
o The name of the target object. The parameter must be encoded in URL Safe Base64.
b The name of the target bucket. This parameter must be encoded in URL Safe Base64. By default, the processed image is saved to the current bucket if this parameter is not specified.

Examples

  • Sample requests
    POST /ObjectName? x-oss-process HTTP/1.1
    Host: oss-example.oss.aliyuncs.com
    Content-Length: 247
    Date: Fri, 04 May 2012 03:21:12 GMT
    Authorization: OSS qn6qrrqxo2oawuk53otfjbyc:KU5h8YMUC78M30dXqf3JxrTZHiA=
    x-oss-process=image/resize,w_100|sys/saveas,o_dGVzdC5qcGc,b_dGVzdA

    In the preceding example, the processed image is saved as the test.jpg object in the test bucket.

  • Sample success responses
    HTTP/1.1 200 OK
    x-oss-request-id: 534B371674E88A4D8906008B
    Date: Fri, 04 May 2012 03:21:12 GMT
    Content-Length: 0
    Connection: keep-alive
    Server: AliyunOSS

SDKs

OSS provides the following SDKs you can use to implement the saveas operation for a processed image: