use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class LiveChannelOperation method listLiveChannels.
/**
* List live channels.
*/
public LiveChannelListing listLiveChannels(ListLiveChannelsRequest listLiveChannelRequest) throws OSSException, ClientException {
assertParameterNotNull(listLiveChannelRequest, "listObjectsRequest");
String bucketName = listLiveChannelRequest.getBucketName();
assertParameterNotNull(bucketName, "bucketName");
ensureBucketNameValid(bucketName);
Map<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put(RequestParameters.SUBRESOURCE_LIVE, null);
populateListLiveChannelsRequestParameters(listLiveChannelRequest, parameters);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(parameters).setOriginalRequest(listLiveChannelRequest).build();
return doOperation(request, listLiveChannelsReponseParser, bucketName, null, true);
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class LiveChannelOperation method generateRtmpUri.
public String generateRtmpUri(GenerateRtmpUriRequest request) throws OSSException, ClientException {
assertParameterNotNull(request, "request");
String bucketName = request.getBucketName();
String liveChannelName = request.getLiveChannelName();
String playlistName = request.getPlaylistName();
Long expires = request.getExpires();
assertParameterNotNull(bucketName, "bucketName");
ensureBucketNameValid(bucketName);
assertParameterNotNull(liveChannelName, "liveChannelName");
ensureLiveChannelNameValid(liveChannelName);
assertParameterNotNull(playlistName, "playlistName");
assertParameterNotNull(expires, "expires");
Credentials currentCreds = this.credsProvider.getCredentials();
String accessId = currentCreds.getAccessKeyId();
String accessKey = currentCreds.getSecretAccessKey();
boolean useSecurityToken = currentCreds.useSecurityToken();
// Endpoint
RequestMessage requestMessage = new RequestMessage(bucketName, liveChannelName);
ClientConfiguration config = this.client.getClientConfiguration();
requestMessage.setEndpoint(OSSUtils.determineFinalEndpoint(this.endpoint, bucketName, config));
// Headers
requestMessage.addHeader(HttpHeaders.DATE, expires.toString());
// Parameters
requestMessage.addParameter(RequestParameters.PLAYLIST_NAME, playlistName);
if (useSecurityToken) {
requestMessage.addParameter(SECURITY_TOKEN, currentCreds.getSecurityToken());
}
// Signature
String canonicalResource = "/" + bucketName + "/" + liveChannelName;
String canonicalString = SignUtils.buildRtmpCanonicalString(canonicalResource, requestMessage, expires.toString());
String signature = ServiceSignature.create().computeSignature(accessKey, canonicalString);
// Build query string
Map<String, String> params = new LinkedHashMap<String, String>();
params.put(HttpHeaders.EXPIRES, expires.toString());
params.put(OSS_ACCESS_KEY_ID, accessId);
params.put(SIGNATURE, signature);
params.putAll(requestMessage.getParameters());
String queryString = HttpUtil.paramToQueryString(params, DEFAULT_CHARSET_NAME);
// Compose rtmp request uri
String uri = requestMessage.getEndpoint().toString();
String livChan = RequestParameters.SUBRESOURCE_LIVE + "/" + liveChannelName;
if (uri.startsWith(OSSConstants.PROTOCOL_HTTP)) {
uri = uri.replaceFirst(OSSConstants.PROTOCOL_HTTP, OSSConstants.PROTOCOL_RTMP);
} else if (uri.startsWith(OSSConstants.PROTOCOL_HTTPS)) {
uri = uri.replaceFirst(OSSConstants.PROTOCOL_HTTPS, OSSConstants.PROTOCOL_RTMP);
} else if (!uri.startsWith(OSSConstants.PROTOCOL_RTMP)) {
uri = OSSConstants.PROTOCOL_RTMP + uri;
}
if (!uri.endsWith("/")) {
uri += "/";
}
uri += livChan + "?" + queryString;
return uri;
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSBucketOperation method setBucketStorageCapacity.
public void setBucketStorageCapacity(SetBucketStorageCapacityRequest setBucketStorageCapacityRequest) throws OSSException, ClientException {
assertParameterNotNull(setBucketStorageCapacityRequest, "setBucketStorageCapacityRequest");
assertParameterNotNull(setBucketStorageCapacityRequest.getUserQos(), "setBucketStorageCapacityRequest.userQos");
String bucketName = setBucketStorageCapacityRequest.getBucketName();
assertParameterNotNull(bucketName, "bucketName");
ensureBucketNameValid(bucketName);
UserQos userQos = setBucketStorageCapacityRequest.getUserQos();
assertParameterNotNull(userQos.getStorageCapacity(), "StorageCapacity");
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_QOS, null);
byte[] rawContent = setBucketQosRequestMarshaller.marshall(userQos);
Map<String, String> headers = new HashMap<String, String>();
addRequestRequiredHeaders(headers, rawContent);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.PUT).setBucket(bucketName).setParameters(params).setHeaders(headers).setInputSize(rawContent.length).setInputStream(new ByteArrayInputStream(rawContent)).setOriginalRequest(setBucketStorageCapacityRequest).build();
doOperation(request, emptyResponseParser, bucketName, null);
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSBucketOperation method deleteBucketWebsite.
/**
* Delete bucket website.
*/
public void deleteBucketWebsite(GenericRequest genericRequest) throws OSSException, ClientException {
assertParameterNotNull(genericRequest, "genericRequest");
String bucketName = genericRequest.getBucketName();
assertParameterNotNull(bucketName, "bucketName");
ensureBucketNameValid(bucketName);
Map<String, String> params = new HashMap<String, String>();
params.put(SUBRESOURCE_WEBSITE, null);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.DELETE).setBucket(bucketName).setParameters(params).setOriginalRequest(genericRequest).build();
doOperation(request, emptyResponseParser, bucketName, null);
}
use of com.aliyun.oss.common.comm.RequestMessage in project aliyun-oss-java-sdk by aliyun.
the class OSSBucketOperation method getBucketStat.
public BucketStat getBucketStat(GenericRequest genericRequest) throws OSSException, ClientException {
assertParameterNotNull(genericRequest, "genericRequest");
String bucketName = genericRequest.getBucketName();
assertParameterNotNull(bucketName, "bucketName");
ensureBucketNameValid(bucketName);
Map<String, String> params = new HashMap<String, String>();
params.put(RequestParameters.SUBRESOURCE_STAT, null);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setBucket(bucketName).setParameters(params).setOriginalRequest(genericRequest).build();
return doOperation(request, getBucketStatResponseParser, bucketName, null, true);
}
Aggregations