Image Persistency

Persistency indicates that images are asynchronously stored in the specified OBS bucket, so that you can access the processed images directly, improving user experience.

Currently, this function can be used only by coding or calling the API. In the image processing request interface, the image processing persistency request is sent in the format of parameter name = parameter value. Table 1 describes the parameters.

Table 1 Persistency

Parameter

Value

Description

x-image-save-object

objectName

This parameter is mandatory.

Specifies the name of the target object, that is, the name of the processed image that will be stored in the bucket.

Object naming requirements are as follows:

  • The value cannot contain the following special characters: \:*?"<>|
  • The value ranges from 1 to 1023 characters.

x-image-save-bucket

bucketName

This parameter is optional.

Specifies the target bucket. The processed images are stored in the bucket. If this parameter is not specified, the images are saved to the current bucket by default.

The bucket name ranges from 1 to 64 characters and must an existing bucket in OBS.

Java Sample Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ObsClient obsClient = null;
String endPoint = "obs-endpoint";
String ak = "your ak";
String sk = "your sk";
try{    
    ObsConfiguration config = new ObsConfiguration();    
    config.setEndPoint(endPoint);   
    obsClient = new ObsClient(ak,sk ,config);    
    TemporarySignatureRequest request = new TemporarySignatureRequest(); 
    request.setObjectKey("test.jpeg");   
    Map<String, Object> queryParams =new HashMap<>();    
    queryParams.put("x-image-process","image/resize,w_100");   
    String objectName = "your saves objectName";
    // Optional parameter
    String bucketName = "your saves Bucket";    
    queryParams.put("x-image-save-object", ServiceUtils.toBase64(objectName.getBytes("UTF-8")));     
    queryParams.put("x-image-save-bucket",ServiceUtils.toBase64(bucketName.getBytes("UTF-8")));     
    request.setQueryParams(queryParams);    
    request.setBucketName("your bucket");    
    TemporarySignatureResponse response = obsClient.createTemporarySignature(request);
    //URL to be accessed
    response.getSignedUrl();
 }catch (Exception e){
...//Handle exceptions.
 }finally{
     if(obsClient != null){
             obsClient.close();   
      }
 }

The object name and bucket name must be Base64 encoded and URL safe. encodedObject = url_safe_base64_encode(name). For example, if the object name is panda.png, the encoded content is cGFuZGEucG5n.