Image Processing Persistence
Overview
BOS supports image persistence. There are two persistence methods:
- Inventory persistence involves processing images that are already present in BOS and saving them back to BOS.
- Incremental persistence involves uploading images to BOS while processing them, with both the original and processed images stored in BOS.
Syntax
Request
1PUT /<ObjectKey> HTTP/1.1
2Host: <BucketName>.bj.bcebos.com
3Date: <Date>
4Authorization: <Authorization_String>
5Content-Type: <type>
6x-bce-process: system/load,b_buc,o_obj|image/<imageprocess>
The request header x-bce-process is required and can be filled in either the header or query
- Use the new version of image processing parameters in the downstream of image
- The system specifies the information to be saved; "load" refers to retrieving an object from a specified bucket, and "save" refers to storing the object into a specified bucket. The supported actions and parameters are detailed as follows:
| action | Parameters | Value | Description | Required or not |
|---|---|---|---|---|
| load | b | - | Bucket name: If it is omitted, the bucket where the original object is located is set by default | No |
| o | - | URL-safe Base64-encoded object name | Yes | |
| save | b | - | Bucket name: If it is omitted, the bucket where the original object is located is set by default | No |
| o | - | URL-safe Base64-encoded object name | Yes |
Inventory persistence
Request
Define a specific persistence request by setting the x-bce-process header in the PutObject request header.
1PUT /<ObjectKey> HTTP/1.1
2Host: <BucketName>.bj.bcebos.com
3Date: <Date>
4Authorization: <Authorization_String>
5Content-Type: <type>
6x-bce-process: system/load,b_buc,o_obj|image/<imageprocess>
Response
Return the processed and persistently saved results
Example
Resize and format-convert the test.jpg stored in the mytest bucket of BOS, then save the processed image as test_resize.bmp in the mytest1 bucket.
1# Request
2PUT /test_resize.bmp HTTP/1.1
3Host: mytest1.bj.bcebos.com
4Date: <Date>
5Authorization: <Authorization_String>
6Content-Type: <type>
7x-bce-process: system/load,b_mytest,o_dGVzdC5qcGc=|image/resize,m_fill,w_100,h_90/format,f_bmp
8# Response
9HTTP/1.1 200 OK
10x-bce-request-id: 4db2b34d-654d-4d8a-b49b-3049ca786409
11Date: Wed, 06 Apr 2016 06:34:40 GMT
12ETag: "1b2cf535f27731c974343645a3985328"
13Content-Length: 0
14Connection: close
15Server: BceBos
Restrictions: Users must have read permission for the mytest bucket and write permission for the mytest1 bucket - both are indispensable
Incremental persistence
Request
Define a specific persistence request by setting the x-bce-process header in the PutObject request header.
1PUT /<ObjectKey> HTTP/1.1
2Host: <BucketName>.bj.bcebos.com
3Date: <Date>
4Authorization: <Authorization_String>
5Content-Type: text/plain
6Content-Length: <Content_Length>
7x-bce-process: image/<image_process>|system/save,b_buc,o_obj
Response
Provide the result of the user upload process.
Example
Upload test.jpg to the mytest bucket, resize and format-convert it, and then save the processed image as test_resize.bmp in the mytest1 bucket.
1# Request
2PUT /test.jpg HTTP/1.1
3Host: mytest.bj.bcebos.com
4Date: Wed, 06 Apr 2016 06:34:40 GMT
5Authorization: <Authorization_String>
6Content-Type: image/jpeg
7Content-Length: 102409
8x-bce-process:image/resize,m_fill,w_100,h_90/format,f_bmp|system/save,b_mytest1,o_dGVzdF9yZXNpemUuYm1w
9[102409 bytes of object data]
10# Response
11HTTP/1.1 200 OK
12x-bce-request-id: 4db2b34d-654d-4d8a-b49b-3049ca786409
13Date: Wed, 06 Apr 2016 06:34:40 GMT
14ETag: "1b2cf535f27731c974343645a3985328"
15Content-Length: 0
16Connection: close
17Server: BceBos
Restrictions: Users must have write permission for the mytest bucket and write permission for the mytest1 bucket - both are indispensable
