/** * Updates the file's properties to the storage service. * <p> * Use {@link CloudFile#downloadAttributes} to retrieve the latest values for the file's properties and metadata * from the Microsoft Azure storage service. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ @DoesServiceRequest public final void uploadProperties() throws StorageException, URISyntaxException { this.uploadProperties(null /* accessCondition */, null /* options */, null /*opContext */); }
/** * Updates the file's properties to the storage service. * <p> * Use {@link CloudFile#downloadAttributes} to retrieve the latest values for the file's properties and metadata * from the Microsoft Azure storage service. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ @DoesServiceRequest public final void uploadProperties() throws StorageException, URISyntaxException { this.uploadProperties(null /* accessCondition */, null /* options */, null /*opContext */); }
/** * Commits the file. * * @throws StorageException * An exception representing any error which occurred during the operation. * @throws URISyntaxException */ @DoesServiceRequest private void commit() throws StorageException, URISyntaxException { if (this.options.getStoreFileContentMD5()) { this.parentFileRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest())); } this.parentFileRef.uploadProperties(this.accessCondition, this.options, this.opContext); }
/** * Commits the file. * * @throws StorageException * An exception representing any error which occurred during the operation. * @throws URISyntaxException */ @DoesServiceRequest private void commit() throws StorageException, URISyntaxException { if (this.options.getStoreFileContentMD5()) { this.parentFileRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest())); } this.parentFileRef.uploadProperties(this.accessCondition, this.options, this.opContext); }
@Test public void testCloudFileUploadEncryption() throws URISyntaxException, StorageException, IOException { this.requestFound = false; OperationContext ctxt = new OperationContext(); ctxt.getRequestCompletedEventHandler().addListener(new StorageEvent<RequestCompletedEvent>() { @Override public void eventOccurred(RequestCompletedEvent eventArg) { assertTrue(eventArg.getRequestResult().isRequestServiceEncrypted()); CloudFileServerEncryptionTests.this.requestFound = true; } }); this.file.uploadText("test", null, null, null, ctxt); assertTrue(this.requestFound); this.requestFound = false; this.file.uploadProperties(null, null, ctxt); assertTrue(this.requestFound); this.requestFound = false; this.file.uploadMetadata(null, null, ctxt); assertTrue(this.requestFound); }
fileRef.downloadAttributes(); fileRef.getProperties().setContentMD5("MDAwMDAwMDA="); fileRef.uploadProperties(null, options, null); fileRef.uploadProperties(null, options, null); fileRef.download(new ByteArrayOutputStream(), null, options, null); fileRef.downloadToByteArray(new byte[4096], 0);
file.getProperties().setContentMD5("MDAwMDAwMDA="); file.getProperties().setContentType("text/html"); file.uploadProperties(); assertTrue(file.getProperties().getLastModified().after(lastModified)); assertTrue(!eTag.equals(file.getProperties().getEtag()));
/** * Test file resizing. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileResize2() throws StorageException, URISyntaxException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file.create(1024); assertEquals(1024, file.getProperties().getLength()); file2.downloadAttributes(); assertEquals(1024, file2.getProperties().getLength()); file2.getProperties().setContentType("text/plain"); file2.uploadProperties(); file.resize(2048); assertEquals(2048, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(2048, file2.getProperties().getLength()); }
/** * Test file resizing. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileResize() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file.create(1024); assertEquals(1024, file.getProperties().getLength()); file2.downloadAttributes(); assertEquals(1024, file2.getProperties().getLength()); file2.getProperties().setContentType("text/plain"); file2.uploadProperties(); file.resize(2048); assertEquals(2048, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(2048, file2.getProperties().getLength()); // Resize to 0 length file.resize(0); assertEquals(0, file.getProperties().getLength()); file.downloadAttributes(); assertEquals("text/plain", file.getProperties().getContentType()); file2.downloadAttributes(); assertEquals(0, file2.getProperties().getLength()); }