Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public PutResult putContent(String fileName, InputStream data)
- throws IOException, ContainerNotFoundException {
- BlobStore blobStore = connectionProvider.getBlobStore();
- String container = connectionProvider.getContainer();
- CountingInputStream countingInputStream = new CountingInputStream(data);
- DigestInputStream md5DigestInputStream = md5InputStream(countingInputStream);
- BlobBuilder builder = blobStore.blobBuilder(fileName);
- builder = builder.name(fileName);
- builder = builder.payload(md5DigestInputStream);
- Blob blob = builder.build();
- blobStore.putBlob(container, blob);
- String md5 = BaseEncoding.base16().lowerCase().encode(md5DigestInputStream.getMessageDigest().digest());
- Long contentLength = countingInputStream.getCount();
- return new PutResult(md5, contentLength);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement