Package io.fathom.cloud.image.ImageServiceImpl

Examples of io.fathom.cloud.image.ImageServiceImpl.ImageImpl


    @Inject
    ImageDataService imageDataService;

    private ImageData findImage(String id) throws CloudException {
        ImageImpl image = imageService.findImage(getProject(), Long.valueOf(id));
        if (image == null) {
            return null;
        }

        return image.getData();
    }
View Full Code Here


    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();
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.image.ImageServiceImpl.ImageImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.