use of com.amazonaws.services.polly.model.transform.SynthesizeSpeechPresignRequestMarshaller in project aws-sdk-android by aws-amplify.
the class AmazonPollyPresigningClient method getPresignedSynthesizeSpeechUrl.
/**
* <p>
* Returns a pre-signed URL for accessing an Amazon Polly resource.
* </p>
* <p>
* Pre-signed URLs allow clients to form a URL for an Amazon Polly
* resource, and then sign it with the current AWS security credentials.
* The pre-signed URL can be shared to other users, allowing access to
* the resource without providing an account's AWS security credentials.
* </p>
* <p>
* Pre-signed URLs are useful in many situations where AWS security
* credentials aren't available from the client that needs to make the
* actual request to Amazon Polly.
* </p>
* <p>
* For example, a pre-signed URL to GET the synthesized speech audio stream
* using the owner's AWS account can be generated and passed to a system
* media player.
* </p>
*
* @param synthesizeSpeechPresignRequest Object providing pre-signed synthesize speech
* request parameters.
* @return Pre-signed URL of audio stream containing synthesized speech
* matching parameters provided in synthesizeSpeechPresignRequest
* that is possible to obtain using HTTP GET method.
*/
public URL getPresignedSynthesizeSpeechUrl(SynthesizeSpeechPresignRequest synthesizeSpeechPresignRequest) {
Request<PresigningRequest> request = new SynthesizeSpeechPresignRequestMarshaller().marshall(synthesizeSpeechPresignRequest);
request.setEndpoint(endpoint);
request.setTimeOffset(timeOffset);
if (synthesizeSpeechPresignRequest.getExpiration() == null) {
synthesizeSpeechPresignRequest.setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * DEFAULT_GET_REQUEST_EXPIRATION_MINUTES));
}
Signer signer = getSignerByURI(endpoint);
if (!(signer instanceof Presigner)) {
throw new AmazonClientException("Unsupported signer");
}
Presigner presigner = (Presigner) signer;
Date expirationDate = synthesizeSpeechPresignRequest.getExpiration();
AWSCredentials credentials = synthesizeSpeechPresignRequest.getRequestCredentials();
if (credentials == null) {
credentials = awsCredentialsProvider.getCredentials();
}
presigner.presignRequest(request, credentials, expirationDate);
// Remove the leading slash (if any) in the resource-path
return ServiceUtils.convertRequestToUrl(request, true);
}
Aggregations