public class GeneratePresignedUrlRequest extends AbstractBceRequest
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.
| Constructor and Description |
|---|
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.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRequestHeaders(String key,
String value)
Adds an additional request header to be included in the pre-signed URL.
|
void |
addRequestParameter(String key,
String value)
Adds an additional request parameter to be included in the pre-signed
URL.
|
String |
getBucketName()
Returns the name of the bucket involved in this request.
|
String |
getContentMd5()
Gets the expected content-md5 header of the request.
|
String |
getContentType()
Gets the expected content-type of the request.
|
int |
getExpiration()
The expiration after which point the new pre-signed URL will no longer
be accepted by BOS.
|
String |
getKey()
Returns the key of the object involved in this request.
|
HttpMethodName |
getMethod()
The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.
|
Map<String,String> |
getRequestHeaders()
Returns the complete map of additional request headers to be included
in the pre-signed URL.
|
Map<String,String> |
getRequestParameters()
Returns the complete map of additional request parameters to be included
in the pre-signed URL.
|
ResponseHeaderOverrides |
getResponseHeaders()
Returns the headers to be overridden in the service response.
|
void |
setBucketName(String bucketName)
Sets the name of the bucket involved in this request.
|
void |
setContentMd5(String contentMd5)
Sets the expected content-md5 header of the request.
|
void |
setContentType(String contentType)
Sets the expected content-type of the request.
|
void |
setExpiration(int expirationInSeconds)
Sets the expiration after which point the new pre-signed URL will no
longer be accepted by BOS.
|
void |
setKey(String key)
Sets the key of the object involved in this request.
|
void |
setMethod(HttpMethodName method)
Sets the HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.
|
void |
setResponseHeaders(ResponseHeaderOverrides responseHeaders)
Sets the headers to be overridden in the service response.
|
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.
|
GeneratePresignedUrlRequest |
withContentMd5(String contentMd5)
Sets the expected content-md5 header of the request and returns this
object, for method chaining.
|
GeneratePresignedUrlRequest |
withContentType(String contentType)
Sets the expected content-type of the request and returns
this object, for method chaining.
|
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.
|
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.
|
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.
|
GeneratePresignedUrlRequest |
withRequestCredentials(BceCredentials credentials) |
GeneratePresignedUrlRequest |
withResponseHeaders(ResponseHeaderOverrides responseHeaders)
Sets the headers to be overridden in the service response and returns
this object, for method chaining.
|
getRequestCredentials, setRequestCredentialspublic GeneratePresignedUrlRequest(String bucketName, String key)
bucketName - The name of the bucket containing the desired BOS
object.key - The key under which the desired BOS object is stored.public GeneratePresignedUrlRequest(String bucketName, String key, HttpMethodName method)
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.public HttpMethodName getMethod()
public void setMethod(HttpMethodName method)
method - The HTTP method (GET, PUT, DELETE, HEAD) to be used in this request.public GeneratePresignedUrlRequest withMethod(HttpMethodName method)
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.public String getBucketName()
public void setBucketName(String bucketName)
bucketName - the name of the bucket involved in this request.public GeneratePresignedUrlRequest withBucketName(String bucketName)
bucketName - the name of the bucket involved in this request.public String getKey()
public void setKey(String key)
key - the key of the object involved in this request.public GeneratePresignedUrlRequest withKey(String key)
key - the key of the object involved in this request.public int getExpiration()
public void setExpiration(int expirationInSeconds)
expirationInSeconds - The expiration after which point the new pre-signed URL will
no longer be accepted by BOS.public GeneratePresignedUrlRequest withExpiration(int expirationInSeconds)
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.public void addRequestParameter(String key, String value)
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.public Map<String,String> getRequestParameters()
public ResponseHeaderOverrides getResponseHeaders()
public void setResponseHeaders(ResponseHeaderOverrides responseHeaders)
responseHeaders - The headers to be overridden in the service response.public GeneratePresignedUrlRequest withResponseHeaders(ResponseHeaderOverrides responseHeaders)
responseHeaders - The headers to be overridden in the service response.GeneratePresignedUrlRequest for method chaining.public void addRequestHeaders(String key, String value)
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.public Map<String,String> getRequestHeaders()
public String getContentType()
public void setContentType(String contentType)
contentType - The expected content-typepublic GeneratePresignedUrlRequest withContentType(String contentType)
contentType - The expected content-typeGeneratePresignedUrlRequest for method chaining.public String getContentMd5()
public void setContentMd5(String contentMd5)
contentMd5 - The expected content-md5 header value.public GeneratePresignedUrlRequest withContentMd5(String contentMd5)
contentMd5 - The expected content-md5 header value.GeneratePresignedUrlRequest for method chaining.public GeneratePresignedUrlRequest withRequestCredentials(BceCredentials credentials)
withRequestCredentials in class AbstractBceRequestCopyright © 2020. All rights reserved.