类 GeneratePresignedUrlRequest


  • public class GeneratePresignedUrlRequest
    extends AbstractBceRequest
    Contains options to generate a pre-signed URL for an Baidu BOS resource.

    Pre-signed URLs allow clients to form a URL for an Baidu BOS resource and sign it with the current BCE security credentials. A pre-signed URL may be passed around for other users to access the resource without providing them access to an account's BCE security credentials.

    • 构造器详细资料

      • GeneratePresignedUrlRequest

        public GeneratePresignedUrlRequest​(String bucketName,
                                           String key)
        Creates a new request for generating a pre-signed URL that can be used as part of an HTTP GET request to access the BOS object stored under the specified key in the specified bucket.
        参数:
        bucketName - The name of the bucket containing the desired BOS object.
        key - The key under which the desired BOS object is stored.
      • GeneratePresignedUrlRequest

        public GeneratePresignedUrlRequest​(String bucketName,
                                           String key,
                                           HttpMethodName method)
        Creates a new request for generating a pre-signed URL that can be used as part of an HTTP request to access the specified BOS resource.

        When specifying an HTTP method, you must send the pre-signed URL with the same HTTP method in order to successfully use the pre-signed URL.

        参数:
        bucketName - The name of the BOS bucket involved in the operation.
        key - The key of the BOS object involved in the operation.
        method - The HTTP method (GET, PUT, DELETE, HEAD) to be used in the request when the pre-signed URL is used.
    • 方法详细资料

      • getMethod

        public HttpMethodName getMethod()
        The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request. The same HTTP method must be used in the request when the pre-signed URL is used.
        返回:
        The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request and when the pre-signed URL is used.
      • setMethod

        public void setMethod​(HttpMethodName method)
        Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request. The same HTTP method must be used in the request when the pre-signed URL is used.
        参数:
        method - The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.
      • withMethod

        public GeneratePresignedUrlRequest withMethod​(HttpMethodName method)
        Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request, and returns this request object to enable additional method calls to be chained together.

        The same HTTP method must be used in the request when the pre-signed URL is used.

        参数:
        method - The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.
        返回:
        The updated request object, so that additional method calls can be chained together.
      • getBucketName

        public String getBucketName()
        Returns the name of the bucket involved in this request.
        返回:
        the name of the bucket involved in this request.
      • setBucketName

        public void setBucketName​(String bucketName)
        Sets the name of the bucket involved in this request.
        参数:
        bucketName - the name of the bucket involved in this request.
      • withBucketName

        public GeneratePresignedUrlRequest withBucketName​(String bucketName)
        Sets the name of the bucket involved in this request, and returns this request object to enable additional method calls to be chained together.
        参数:
        bucketName - the name of the bucket involved in this request.
        返回:
        The updated request object, so that additional method calls can be chained together.
      • getKey

        public String getKey()
        Returns the key of the object involved in this request.
        返回:
        The key of the object involved in this request.
      • setKey

        public void setKey​(String key)
        Sets the key of the object involved in this request.
        参数:
        key - the key of the object involved in this request.
      • withKey

        public GeneratePresignedUrlRequest withKey​(String key)
        Sets the key of the object involved in this request, and returns this request object to enable additional method calls to be chained together.
        参数:
        key - the key of the object involved in this request.
        返回:
        The updated request object, so that additional method calls can be chained together.
      • getExpiration

        public int getExpiration()
        The expiration after which point the new pre-signed URL will no longer be accepted by BOS. If not specified, a default value will be supplied.
        返回:
        The expiration date at which point the new pre-signed URL will no longer be accepted by BOS.
      • setExpiration

        public void setExpiration​(int expirationInSeconds)
        Sets the expiration after which point the new pre-signed URL will no longer be accepted by BOS. If not specified, a default value will be supplied.
        参数:
        expirationInSeconds - The expiration after which point the new pre-signed URL will no longer be accepted by BOS.
      • withExpiration

        public GeneratePresignedUrlRequest withExpiration​(int expirationInSeconds)
        Sets the expiration after which point the new pre-signed URL will no longer be accepted by BOS, and returns this request object to enable additional method calls to be chained together.

        If not specified, a default value will be supplied.

        参数:
        expirationInSeconds - The expiration after which point the new pre-signed URL will no longer be accepted by BOS.
        返回:
        The updated request object, so that additional method calls can be chained together.
      • addRequestParameter

        public void addRequestParameter​(String key,
                                        String value)
        Adds an additional request parameter to be included in the pre-signed URL. Adding additional request parameters enables more advanced pre-signed URLs, such as accessing BOS's torrent resource for an object, or for specifying a version ID when accessing an object.
        参数:
        key - The name of the request parameter, as it appears in the URL's query string.
        value - The (optional) value of the request parameter being added.
      • getRequestParameters

        public Map<String,​String> getRequestParameters()
        Returns the complete map of additional request parameters to be included in the pre-signed URL.
        返回:
        The complete map of additional request parameters to be included in the pre-signed URL.
      • getResponseHeaders

        public ResponseHeaderOverrides getResponseHeaders()
        Returns the headers to be overridden in the service response.
        返回:
        the headers to be overridden in the service response.
      • setResponseHeaders

        public void setResponseHeaders​(ResponseHeaderOverrides responseHeaders)
        Sets the headers to be overridden in the service response.
        参数:
        responseHeaders - The headers to be overridden in the service response.
      • addRequestHeaders

        public void addRequestHeaders​(String key,
                                      String value)
        Adds an additional request header to be included in the pre-signed URL.
        参数:
        key - The name of the request header, as it appears in the URL's header.
        value - The (optional) value of the request header being added.
      • getRequestHeaders

        public Map<String,​String> getRequestHeaders()
        Returns the complete map of additional request headers to be included in the pre-signed URL.
        返回:
        The complete map of additional request headers to be included in the pre-signed URL.
      • getContentType

        public String getContentType()
        Gets the expected content-type of the request. The content-type is included in the signature.
        返回:
        The expected content-type
      • setContentType

        public void setContentType​(String contentType)
        Sets the expected content-type of the request. The content-type is included in the signature.
        参数:
        contentType - The expected content-type
      • getContentMd5

        public String getContentMd5()
        Gets the expected content-md5 header of the request. This header value will be included when calculating the signature, and future requests must include the same content-md5 header value to access the presigned URL.
        返回:
        The expected content-md5 header value.
      • setContentMd5

        public void setContentMd5​(String contentMd5)
        Sets the expected content-md5 header of the request. This header value will be included when calculating the signature, and future requests must include the same content-md5 header value to access the presigned URL.
        参数:
        contentMd5 - The expected content-md5 header value.
      • withContentMd5

        public GeneratePresignedUrlRequest withContentMd5​(String contentMd5)
        Sets the expected content-md5 header of the request and returns this object, for method chaining.
        参数:
        contentMd5 - The expected content-md5 header value.
        返回:
        This GeneratePresignedUrlRequest for method chaining.