jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Coedo <notificati...@github.com>
Subject Re: [jclouds-labs] JCLOUDS-826: Add blob operations (#176)
Date Wed, 17 Jun 2015 21:25:09 GMT
> +   private List<Long> storeData(InputStream data) throws IOException {
> +      ImmutableList.Builder<Long> chunks = ImmutableList.builder();
> +      int bytes;
> +      byte[] buffer = new byte[JdbcConstants.DEFAULT_CHUNK_SIZE];
> +      while ((bytes = data.read(buffer, 0, JdbcConstants.DEFAULT_CHUNK_SIZE)) != -1)
{
> +         chunks.add(chunkRepository.create(new ChunkEntity(buffer, bytes)).getId());
> +         buffer = new byte[JdbcConstants.DEFAULT_CHUNK_SIZE];
> +      }
> +      data.close();
> +      return chunks.build();
> +   }
> +
> +   private void checkIntegrity(Blob blob, BlobEntity entity) throws IOException {
> +      HashCode hash = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
> +      if (hash != null) {
> +         HashingInputStream his = new HashingInputStream(Hashing.md5(), new JdbcInputStream(this,
entity.getPayload().getChunks()));

I could make this explicit, but I think it's safe to leave it opened (JdbcInputStream close
method does nothing).

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/176/files#r32676697
Mime
View raw message