Package org.dddlib.image.api.pojo

Examples of org.dddlib.image.api.pojo.ImageFile


        String file = getClass().getResource("/aaa.jpg").getFile();
        ImageAccess imageAccess = new CacheImageAccess(cache);
        String uuid = imageAccess.saveImageFile(FileUtils.readFileToByteArray(new File(file)), "aaa.jpg");
        System.out.println(uuid);
        assertTrue(uuid != null);
        ImageFile imageFile = imageAccess.getImageFile(uuid);
        assertTrue(imageFile.getContent() != null);
        assertTrue(imageFile.getFileName().equals("aaa.jpg"));
    }
View Full Code Here


        Cache redisCache = new RedisBasedCache("127.0.0.1", 6379);
        ImageAccess imageAccess = new CacheImageAccess(redisCache);
        String uuid = imageAccess.saveImageFile(FileUtils.readFileToByteArray(new File(file)), "aaa.jpg");
        System.out.println(uuid);
        assertTrue(uuid != null);
        ImageFile imageFile = imageAccess.getImageFile(uuid);
        assertTrue(imageFile.getContent() != null);
        assertTrue(imageFile.getFileName().equals("aaa.jpg"));
    }
View Full Code Here

    public String saveImageFile(byte[] content, String filename) {
        assert cache!=null : "cache不能为空";
        assert content!=null : "图片内容不能为空";
        assert filename!=null : "图片文件名不能为空";

        ImageFile imageFile = new ImageFile(content,filename);
        String uuid = UUID.randomUUID().toString().toUpperCase();
        cache.put(uuid, imageFile);
        return uuid;
    }
View Full Code Here

    public ImageFile getImageFile(String imageID) {
        assert cache!=null : "cache不能为空";
        assert imageID!=null :"请指定图片ID";

        if (cache.containsKey(imageID)) {
            ImageFile imageFile = (ImageFile) cache.get(imageID);
            return imageFile;
        }
        return null;
    }
View Full Code Here

        File file = new File(directory + File.separator + imageId);
        try {
            if (file.exists()) {
                byte[] contents = FileUtils.readFileToByteArray(file);
                String fileName = imageId.substring(imageId.indexOf(FILE_SUFFIX) + FILE_SUFFIX.length());
                ImageFile imageFile = new ImageFile(contents, fileName);
                return imageFile;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

        String mediaId =  imageAccess.saveImageFile(FileUtils.readFileToByteArray(new File(file)),"abc.jpg");

        assertTrue(mediaId!=null);

        ImageFile imageFile = imageAccess.getImageFile(mediaId);

        assertTrue(imageFile.getContent()!=null);
        assertTrue(imageFile.getFileName().equals("abc.jpg"));

    }
View Full Code Here

TOP

Related Classes of org.dddlib.image.api.pojo.ImageFile

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.