Package io.fathom.cloud.blobs

Examples of io.fathom.cloud.blobs.BlobStore


        file.setLength(blob.dataLength);

        updateAttributes(userAttributes, file.getAttributesBuilder());

        if (PARANOID) {
            BlobStore blobStore = getBlobStore(project);
            sanityCheck(blobStore, file);
        }

        storeDirectory(getDirectoryStorage(project), newDir);
    }
View Full Code Here


        ResumableMD5Digest md5 = ResumableMD5Digest.get();
        if (file.hasHashResume() && !file.getHashResume().isEmpty()) {
            md5.setState(file.getHashResume(), file.getLength());
            md5.update(blob.data);
        } else {
            BlobStore blobStore = getBlobStore(project);

            CloudObject cloudObject = new CloudObject(oldFileData);
            try (InputStream is = cloudObject.getInputStream(blobStore)) {
                md5.update(is);
            }
            md5.update(blob.data);
        }

        ByteString hashResume = md5.getState();
        ByteString hash = ByteString.copyFrom(md5.digest());

        file.setHash(hash);

        // NOTE: hashResume can contain plaintext. Careful around encryption!
        file.setHashResume(hashResume);

        file.setLength(file.getLength() + blob.dataLength);

        if (PARANOID) {
            BlobStore blobStore = getBlobStore(project);
            sanityCheck(blobStore, file);
        }

        storeDirectory(getDirectoryStorage(project), newDir);
View Full Code Here

        CloudObject object = new CloudObject(file.getData());

        final InputStream is;
        try {
            BlobStore blobStore = getBlobStore(file.getProject());
            is = object.getInputStream(blobStore, from, to);
        } catch (IOException e) {
            throw new IllegalStateException("Error opening file", e);
        }
View Full Code Here

            return null;
        }

        CloudObject object = new CloudObject(fsFile.getData());

        BlobStore blobStore = getBlobStore(project);
        return object.asByteSource(blobStore, from, to);
    }
View Full Code Here

            long len = range.getEnd() - range.getStart();
            log.info("{} {}", i, len);
        }
        log.info("Chose merge {}-{}", bestStart, bestEnd);

        BlobStore blobStore = fs.getBlobStore(project);
        List<FileRange> newRanges = Lists.newArrayList();

        for (int i = 0; i < bestStart; i++) {
            newRanges.add(file.getRanges(i));
        }

        try (TempFile tempFile = TempFile.create()) {
            FileRange.Builder c = FileRange.newBuilder();

            Hasher md5 = Hashing.md5().newHasher();
            try (OutputStream fos = new HashingOutputStream(new FileOutputStream(tempFile.getFile()), md5)) {
                for (int i = bestStart; i < bestEnd; i++) {
                    FileRange range = file.getRanges(i);
                    if (i == bestStart) {
                        c.setStart(range.getStart());
                    }
                    if (i == (bestEnd - 1)) {
                        c.setEnd(range.getEnd());
                    }

                    final BlobData blob = blobStore.find(range.getContentKey());
                    if (blob == null) {
                        throw new IOException("Unable to open storage for range: " + range);
                    }

                    blob.copyTo(fos);
                }
            }

            if (!c.hasStart() || !c.hasEnd()) {
                throw new IllegalStateException();
            }

            ByteString hash = ByteString.copyFrom(md5.hash().asBytes());
            BlobData blobData = new BlobData(tempFile.getFile(), hash);
            blobStore.put(blobData);

            if (PARANOID) {
                BlobData blob = blobStore.find(blobData.getHash());
                if (blob == null) {
                    throw new IllegalStateException();
                }
                ByteString checkHash = ByteString.copyFrom(blob.hash(Hashing.md5()).asBytes());
                if (!blobData.getHash().equals(checkHash)) {
View Full Code Here

    @Inject
    BlobStoreFactory blobStoreFactory;

    @Override
    public String storeImageFile(BlobData data) throws IOException {
        BlobStore blobStore = getBlobStore();

        blobStore.put(data);

        return Hex.toHex(data.getHash().toByteArray());
    }
View Full Code Here

        return blobStoreFactory.get("images");
    }

    @Override
    public BlobData getImageFile(String cookie) throws IOException {
        BlobStore blobStore = getBlobStore();

        ByteString key = ByteString.copyFrom(Hex.fromHex(cookie));

        BlobData blobData = blobStore.find(key);

        return blobData;
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.blobs.BlobStore

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.