public Response createImage(File file) throws CloudException, IOException {
if (file == null) {
throw new IllegalArgumentException("No content supplied");
}
ImageImpl image;
{
Map<String, String> metadata = extractHeaders();
if (metadata.containsKey("size")) {
long size = Long.valueOf(metadata.get(ImageService.METADATA_KEY_SIZE));
if (size != file.length()) {
throw new IllegalArgumentException();
}
}
metadata.put("size", "" + Long.valueOf(file.length()));
image = imageService.createImage(getProject().getId(), metadata);
}
{
BlobData data = BlobData.build(file);
image = imageService.uploadData(image, data);
}
WrappedImage result = new WrappedImage();
result.image = toModel(image.getData());
return Response.status(Status.CREATED).entity(result).type(MediaType.APPLICATION_JSON_TYPE).build();
}