private int getClaimedObjects(CloudBlockBlob blob, long id) throws IOException { try { String[] hs = this.getStrings(blob); HashMap<String, String> md = blob.getMetadata(); if (!md.containsKey("encrypt")) { blob.downloadAttributes(); md = blob.getMetadata(); } int claims = 0; for (String ha : hs) { byte[] b = BaseEncoding.base64().decode(ha.split(":")[0]); if (HCServiceProxy.getHashesMap().mightContainKey(b, id)) claims++; } return claims; } catch (Exception e) { throw new IOException(e); } }
@Override public HashMap<String, String> getUserMetaData(String object) throws IOException { try { CloudBlockBlob blob = container.getBlockBlobReference(object); blob.downloadAttributes(); return blob.getMetadata(); } catch (Exception e) { SDFSLogger.getLog().info("unable to download attribute", e); throw new IOException(e); } }
private String[] getStrings(CloudBlockBlob blob) throws StorageException, IOException { HashMap<String, String> md = blob.getMetadata(); byte[] nm = new byte[(int) blob.getProperties().getLength()]; blob.downloadToByteArray(nm, 0, null, null, opContext); if (!md.containsKey("encrypt")) { blob.downloadAttributes(); md = blob.getMetadata(); } boolean encrypt = Boolean.parseBoolean(md.get("encrypt")); if (encrypt) { nm = EncryptUtils.decryptCBC(nm); } boolean compress = Boolean.parseBoolean(md.get("lz4Compress")); if (compress) { int size = Integer.parseInt(md.get("size")); nm = CompressionUtils.decompressLz4(nm, size); } String st = new String(nm); return st.split(","); }
sasBlob.download(new FileOutputStream(fileTarget)); HashMap<String, String> user = new HashMap<String, String>(); user = sasBlob.getMetadata(); String name = (user.get("firstname") + " " + user.get("lastname")); String age = ("age: " + user.get("age"));
@Override public Map<String, String> getBucketInfo() { try { String lbi = "bucketinfo/" + EncyptUtils.encHashArchiveName(Main.DSEID, Main.chunkStoreEncryptionEnabled); CloudBlockBlob blob = container.getBlockBlobReference(lbi); blob.downloadAttributes(); HashMap<String, String> md = blob.getMetadata(); return md; } catch (Exception e) { SDFSLogger.getLog().warn("unable to update metadata for bucket" + Main.DSEID, e); return null; } }
CloudBlockBlob blob = container.getBlockBlobReference(lbi); blob.downloadAttributes(); HashMap<String, String> md = blob.getMetadata(); Long.parseLong(md.get("currentlength")); return true;
CloudBlockBlob blob = container.getBlockBlobReference(lbi); blob.downloadAttributes(); HashMap<String, String> md = blob.getMetadata(); md.put("currentlength", Long.toString(HashBlobArchive.getLength())); md.put("compressedlength", Long.toString(HashBlobArchive.getCompressedLength()));
CloudBlockBlob cblob = container.getBlockBlobReference(lbi); cblob.downloadAttributes(); HashMap<String, String> md = cblob.getMetadata(); long dur = System.currentTimeMillis() - Long.parseLong(md.get("lastupdated")); if (dur < (60000 * 2)) {
(int) blob.getProperties().getLength()); blob.download(out); HashMap<String, String> metaData = blob.getMetadata(); byte[] data = out.toByteArray(); int size = 0;
@Override protected Map<String, String> doGetMeta(String fullPath) { try { CloudBlockBlob blob = blobContainer.getBlockBlobReference(fullPath); blob.downloadAttributes(); Map<String, String> meta = C.newMap(blob.getMetadata()); meta.put(ISObject.ATTR_CONTENT_TYPE, blob.getProperties().getContentType()); return meta; } catch (Exception e) { throw E.unexpected(e); } }
@Override public void checkoutObject(long id, int claims) throws IOException { try { CloudBlockBlob cblob = container.getBlockBlobReference(this.getClaimName(id)); if (cblob.exists()) return; else { String haName = EncyptUtils.encHashArchiveName(id, Main.chunkStoreEncryptionEnabled); CloudBlockBlob kblob = container.getBlockBlobReference("keys/" + haName); kblob.downloadAttributes(); HashMap<String, String> metaData = kblob.getMetadata(); cblob.setMetadata(metaData); cblob.uploadText(Long.toString(System.currentTimeMillis())); } } catch (Exception e) { throw new IOException(e); } }
HashMap<String, String> bmd = blob.getMetadata(); bmd.remove("deletedobjects"); bmd.remove("deleted");
@Override protected void doPut(String fullPath, ISObject stuff, Map<String, String> attrs) { try { CloudBlockBlob blob = blobContainer.getBlockBlobReference(fullPath); if (!(stuff instanceof SObject.InputStreamSObject)) { blob.upload(stuff.asInputStream(), stuff.getLength()); } BlobProperties props = blob.getProperties(); // content-type contains "-" which is illegal character in C# identifier // so we have to remove it from meta map String contentType = attrs.remove(ISObject.ATTR_CONTENT_TYPE); if (S.notBlank(contentType)) { props.setContentType(contentType); } blob.uploadProperties(); blob.getMetadata().putAll(attrs); blob.uploadMetadata(); } catch (Exception e) { throw E.unexpected(e); } }
HashMap<String, String> metadata = blob.getMetadata(); switch (activity) { case Acquire:
Cipher cipher = options.getEncryptionPolicy().createAndSetEncryptionContext(this.getMetadata(), false /* noPadding */); return new BlobEncryptStream(this, accessCondition, options, opContext, cipher); } else {
@Test @Category(SlowTests.class) public void testCopyBlockBlobSas() throws Exception { // Create source on server. final CloudBlobContainer container = BlobTestHelper.getRandomContainerReference(); try { container.create(); final CloudBlockBlob source = container.getBlockBlobReference("source"); source.getMetadata().put("Test", "value"); final String data = "String data"; source.uploadText(data, Constants.UTF8_CHARSET, null, null, null); final CloudFile destination = doCloudBlobCopy(source, data.length()); final String copyData = destination.downloadText(Constants.UTF8_CHARSET, null, null, null); assertEquals(data, copyData); } finally { container.deleteIfExists(); } }
source.getMetadata().put("Test", "value"); source.uploadMetadata(); copy.getMetadata().put("Test2", "value2"); String copyId = copy.startCopy(BlobTestHelper.defiddler(source)); BlobTestHelper.waitForCopy(copy); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value2", copy.getMetadata().get("Test2")); assertFalse(copy.getMetadata().containsKey("Test"));
source.getMetadata().put("Test", "value"); source.uploadMetadata(); source.getMetadata().put("Test", "newvalue"); source.uploadMetadata(); source.getProperties().setContentMD5(null); assertFalse(source.getMetadata().get("Test").equals(snapshot.getMetadata().get("Test"))); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value", copy.getMetadata().get("Test"));
ByteArrayInputStream stream = new ByteArrayInputStream(buffer); source.upload(stream, buffer.length); source.getMetadata().put("Test", "value"); source.uploadMetadata(); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value", copySas.getMetadata().get("Test")); assertEquals(copyId, copySas.getCopyState().getCopyId());
ByteArrayInputStream stream = new ByteArrayInputStream(buffer); source.upload(stream, buffer.length); source.getMetadata().put("Test", "value"); source.uploadMetadata();