jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Gaul <notificati...@github.com>
Subject Re: [jclouds-labs] JCLOUDS-826: Add blob operations (#176)
Date Mon, 15 Jun 2015 22:20:04 GMT
> +   @Transactional
> +   public boolean blobExists(String containerName, String key) {
> +      return findBlobById(containerName, key) != null;
> +   }
> +
> +   @Transactional(rollbackOn = IOException.class)
> +   public BlobEntity createOrModifyBlob(String containerName, Blob blob, BlobAccess
blobAccess) throws IOException {
> +      String key = blob.getMetadata().getName();
> +      Date creationDate = null;
> +      BlobEntity oldBlobEntity = findBlobById(containerName, key);
> +      if (oldBlobEntity != null) {
> +         creationDate = oldBlobEntity.getCreationDate();
> +         deleteBlob(containerName, key);
> +      }
> +      BlobEntity blobEntity = blobToBlobEntity.apply(blob);
> +      blobEntity.getPayload().setChunks(storeData(blob.getPayload().openStream()));

Do you need to close the `InputStream`?  Shouldn't you also calculate the hash while copying
instead of re-reading from the  database below?

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