private long getOriginalFileSize(CloudPageBlob pageBlobReference) throws StorageException { long size = 0; pageBlobReference.downloadAttributes(); HashMap<String, String> map = pageBlobReference.getMetadata(); if (map != null && map.size() > 0) { try { size = Long.parseLong(map.get(ORIGINAL_SIZE_KEY)); } catch (Exception e) { logger.error("File size metadata missing or is not a number."); } } return size; } }
@Test @Category(SlowTests.class) public void testCopyPageBlobSas() throws Exception { // Create source on server. final CloudBlobContainer container = BlobTestHelper.getRandomContainerReference(); try { container.create(); final CloudPageBlob source = container.getPageBlobReference("source"); source.getMetadata().put("Test", "value"); final int length = 512; final ByteArrayInputStream data = BlobTestHelper.getRandomDataStream(length); source.upload(data, length); final CloudFile destination = doCloudBlobCopy(source, length); final ByteArrayOutputStream copyData = new ByteArrayOutputStream(); destination.download(copyData); BlobTestHelper.assertStreamsAreEqual(data, new ByteArrayInputStream(copyData.toByteArray())); } finally { container.deleteIfExists(); } }
cipher = options.getEncryptionPolicy().createAndSetEncryptionContext(this.getMetadata(), true /* noPadding */);
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"));
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"));
ByteArrayInputStream stream = new ByteArrayInputStream(buffer); source.upload(stream, buffer.length); source.getMetadata().put("Test", "value"); source.uploadMetadata(); 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());