use of org.jclouds.http.HttpResponse in project legacy-jclouds-examples by jclouds.
the class GenerateTempURL method generateDeleteTempURL.
private void generateDeleteTempURL() throws IOException {
System.out.println("Generate DELETE Temp URL");
HttpRequest request = storageContext.getSigner().signRemoveBlob(Constants.CONTAINER, FILENAME);
System.out.println(" " + request.getMethod() + " " + request.getEndpoint());
// DELETE the file using jclouds
HttpResponse response = storageContext.utils().http().invoke(request);
int statusCode = response.getStatusCode();
if (statusCode >= 200 && statusCode < 299) {
System.out.println(" DELETE Success (" + statusCode + ")");
} else {
throw new HttpResponseException(null, response);
}
}
use of org.jclouds.http.HttpResponse in project legacy-jclouds-examples by jclouds.
the class GenerateTempURL method generatePutTempURL.
private void generatePutTempURL() throws IOException {
System.out.println("Generate PUT Temp URL");
String payload = "This object will be public for 10 minutes.";
Blob blob = storage.blobBuilder(FILENAME).payload(payload).contentType("text/plain").build();
HttpRequest request = storageContext.getSigner().signPutBlob(Constants.CONTAINER, blob, TEN_MINUTES);
System.out.println(" " + request.getMethod() + " " + request.getEndpoint());
// PUT the file using jclouds
HttpResponse response = storageContext.utils().http().invoke(request);
int statusCode = response.getStatusCode();
if (statusCode >= 200 && statusCode < 299) {
System.out.println(" PUT Success (" + statusCode + ")");
} else {
throw new HttpResponseException(null, response);
}
}
Aggregations