/** * Uploads the file's metadata 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 uploadMetadata() throws StorageException, URISyntaxException { this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Uploads the file's metadata 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 uploadMetadata() throws StorageException, URISyntaxException { this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */); }
@Test public void testApiVersion() throws InvalidKeyException, StorageException, URISyntaxException { SharedAccessFilePolicy policy = createSharedAccessPolicy( EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.WRITE, SharedAccessFilePermissions.LIST, SharedAccessFilePermissions.DELETE), 300); String sas = this.file.generateSharedAccessSignature(policy, null); // should not be appended before signing assertEquals(-1, sas.indexOf(Constants.QueryConstants.API_VERSION)); OperationContext ctx = new OperationContext(); ctx.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() { @Override public void eventOccurred(ResponseReceivedEvent eventArg) { // should be appended after signing HttpURLConnection conn = (HttpURLConnection) eventArg.getConnectionObject(); assertTrue(conn.getURL().toString().indexOf(Constants.QueryConstants.API_VERSION) != -1); } }); CloudFile sasFile = new CloudFile(new URI(this.file.getUri().toString() + "?" + sas)); sasFile.uploadMetadata(null, null, ctx); }
/** * Test file creation with metadata. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileCreateWithMetadata() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); HashMap<String, String> meta = new HashMap<String, String>(); meta.put("key1", "value1"); file.setMetadata(meta); file.create(1024); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file2.downloadAttributes(); assertEquals(1, file2.getMetadata().size()); assertEquals("value1", file2.getMetadata().get("key1")); file2.setMetadata(new HashMap<String, String>()); file2.uploadMetadata(); file.downloadAttributes(); assertEquals(0, file.getMetadata().size()); }
meta.put("key1", "value1"); file.setMetadata(meta); file.uploadMetadata(); meta2.put("key2", "value2"); file.setMetadata(meta2); file.uploadMetadata(); snapshotFile.downloadAttributes();
@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); }
file.uploadMetadata(); fail("Shouldn't get here");
metadata.put("a", "value"); fileRef.setMetadata(metadata); fileRef.uploadMetadata(); stream.reset(); stream.read(new byte[4096]);
permissions.contains(SharedAccessFilePermissions.READ)) { file.downloadAttributes(); file.uploadMetadata(); file.uploadMetadata(); Assert.fail();