Search in sources :

Example 1 with TemporarySignatureResponse

use of com.obs.services.model.TemporarySignatureResponse in project jeesuite-libs by vakinge.

the class HuaweicloudProvider method generatePresignedUrl.

@Override
protected String generatePresignedUrl(String bucketName, String fileKey, int expireInSeconds) {
    // 默认5分钟, 最长7天
    if (!exists(bucketName, fileKey)) {
        throw new JeesuiteBaseException("对象[bucketName=" + bucketName + ",fileKey=" + fileKey + "]不存在");
    }
    TemporarySignatureRequest req = new TemporarySignatureRequest(HttpMethodEnum.GET, expireInSeconds);
    req.setBucketName(bucketName);
    req.setObjectKey(fileKey);
    TemporarySignatureResponse res = obsClient.createTemporarySignature(req);
    String signedUrl = res.getSignedUrl();
    return signedUrl;
}
Also used : JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) TemporarySignatureResponse(com.obs.services.model.TemporarySignatureResponse) TemporarySignatureRequest(com.obs.services.model.TemporarySignatureRequest)

Example 2 with TemporarySignatureResponse

use of com.obs.services.model.TemporarySignatureResponse in project ais-sdk by huaweicloudsdk.

the class SimpleObsClient method generateSignedUrl.

protected String generateSignedUrl(HttpMethodEnum method, String bucketName, String objectKey, long expireTime) {
    TemporarySignatureRequest req = new TemporarySignatureRequest(method, expireTime);
    req.setBucketName(bucketName);
    req.setObjectKey(objectKey);
    TemporarySignatureResponse res = obsClient.createTemporarySignature(req);
    System.out.println("temporary signature url:");
    System.out.println("\t" + res.getSignedUrl());
    return res.getSignedUrl();
}
Also used : TemporarySignatureResponse(com.obs.services.model.TemporarySignatureResponse) TemporarySignatureRequest(com.obs.services.model.TemporarySignatureRequest)

Aggregations

TemporarySignatureRequest (com.obs.services.model.TemporarySignatureRequest)2 TemporarySignatureResponse (com.obs.services.model.TemporarySignatureResponse)2 JeesuiteBaseException (com.mendmix.common.JeesuiteBaseException)1