/** * Returns the canonical name for shared access. * * @return the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String shareName = this.getName(); return String.format("/%s/%s/%s", SR.FILE, accountName, shareName); }
/** * Returns the canonical name for shared access. * * @return the canonical name for shared access. */ private String getSharedAccessCanonicalName() { String accountName = this.getServiceClient().getCredentials().getAccountName(); String shareName = this.getName(); return String.format("/%s/%s/%s", SR.FILE, accountName, shareName); }
/** * Creates an instance of the <code>CloudFile</code> class using the specified address, share, * and client. * * @param uri * A {@link StorageUri} that represents the file directory's address. * @param fileName * A <code>String</code> that represents the name of the file. * @param share * A {@link CloudFileShare} object that represents the associated file share. */ protected CloudFile(final StorageUri uri, final String fileName, final CloudFileShare share) { Utility.assertNotNull("uri", uri); Utility.assertNotNull("fileName", fileName); Utility.assertNotNull("share", share); this.name = fileName; this.fileServiceClient = share.getServiceClient(); this.share = share; this.storageUri = uri; }
/** * Creates an instance of the <code>CloudFile</code> class using the specified address, share, * and client. * * @param uri * A {@link StorageUri} that represents the file directory's address. * @param fileName * A <code>String</code> that represents the name of the file. * @param share * A {@link CloudFileShare} object that represents the associated file share. */ protected CloudFile(final StorageUri uri, final String fileName, final CloudFileShare share) { Utility.assertNotNull("uri", uri); Utility.assertNotNull("fileName", fileName); Utility.assertNotNull("share", share); this.name = fileName; this.fileServiceClient = share.getServiceClient(); this.share = share; this.storageUri = uri; }
/** * Creates an instance of the <code>CloudFileDirectory</code> class using the specified address, share, * and client. * * @param uri * A {@link StorageUri} that represents the file directory's address. * @param directoryName * A <code>String</code> that represents the name of the directory. * @param share * A {@link CloudFileShare} object that represents the associated file share. */ protected CloudFileDirectory(final StorageUri uri, final String directoryName, final CloudFileShare share) { Utility.assertNotNull("uri", uri); Utility.assertNotNull("directoryName", directoryName); Utility.assertNotNull("share", share); this.name = directoryName; this.fileServiceClient = share.getServiceClient(); this.share = share; this.storageUri = uri; }
/** * Creates an instance of the <code>CloudFileDirectory</code> class using the specified address, share, * and client. * * @param uri * A {@link StorageUri} that represents the file directory's address. * @param directoryName * A <code>String</code> that represents the name of the directory. * @param share * A {@link CloudFileShare} object that represents the associated file share. */ protected CloudFileDirectory(final StorageUri uri, final String directoryName, final CloudFileShare share) { Utility.assertNotNull("uri", uri); Utility.assertNotNull("directoryName", directoryName); Utility.assertNotNull("share", share); this.name = directoryName; this.fileServiceClient = share.getServiceClient(); this.share = share; this.storageUri = uri; }
readListShare.getServiceClient().getCredentials().getClass().toString()); readListShare.getStorageUri(), this.share.generateSharedAccessSignature(null, "readlist"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), shareFromUri.getServiceClient().getCredentials().getClass().toString()); CloudFileClient client = new CloudFileClient(this.share.getServiceClient().getStorageUri(), creds); shareFromClient.getServiceClient().getCredentials().getClass().toString()); assertEquals(client, shareFromClient.getServiceClient());
new CloudFileShare(PathUtility.addToQuery(httpUri, shareSasHttps)); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), httpShare.getServiceClient().getCredentials().getClass().toString()); CloudFile httpFile = httpShare.getRootDirectoryReference().getFileReference(this.file.getName()); httpFile.download(new ByteArrayOutputStream()); new CloudFileShare(PathUtility.addToQuery(httpsUri, shareSasHttps)); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), httpsShare.getServiceClient().getCredentials().getClass().toString()); CloudFile httpsFile = httpsShare.getRootDirectoryReference().getFileReference(this.file.getName()); httpsFile.download(new ByteArrayOutputStream()); new CloudFileShare(PathUtility.addToQuery(httpUri, shareSasHttp)); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), httpShare.getServiceClient().getCredentials().getClass().toString()); CloudFile httpFile = httpShare.getRootDirectoryReference().getFileReference(this.file.getName()); httpFile.download(new ByteArrayOutputStream()); new CloudFileShare(PathUtility.addToQuery(httpsUri, shareSasHttp)); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), httpsShare.getServiceClient().getCredentials().getClass().toString()); httpsFile = httpsShare.getRootDirectoryReference().getFileReference(this.file.getName()); httpsFile.download(new ByteArrayOutputStream());
/** * Test that Share Quota can be set, but only to allowable values. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCloudFileShareQuotaListing() throws StorageException, URISyntaxException { int shareQuota = 16; this.share.getProperties().setShareQuota(shareQuota); this.share.createIfNotExists(); Iterable<CloudFileShare> shares = this.share.getServiceClient().listShares(this.share.getName()); for (CloudFileShare fileShare : shares) { assertEquals(shareQuota, fileShare.getProperties().getShareQuota().intValue()); } }
assertEquals("value1", this.share.getMetadata().get("key1")); CloudFileShare share2 = this.share.getServiceClient().getShareReference(this.share.getName()); share2.downloadAttributes(); assertEquals(1, share2.getMetadata().size()); assertEquals("value2", this.share.getMetadata().get("key2")); Iterable<CloudFileShare> shares = this.share.getServiceClient().listShares(this.share.getName(), EnumSet.of(ShareListingDetails.METADATA), null, null);
noneShare.getServiceClient().getCredentials().getClass().toString()); oneShare.getServiceClient().getCredentials().getClass().toString()); allShare.getServiceClient().getCredentials().getClass().toString());
uriBuilder.add("sharesnapshot", snapshot.snapshotID); CloudFileShare snapshotRef5 = new CloudFileShare(uriBuilder.addToURI(this.share.getUri()), this.share.getServiceClient().getCredentials()); assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID); assertTrue(snapshotRef5.exists());
uriBuilder.add("sharesnapshot", snapshot.snapshotID); uriBuilder.add("restype", "directory"); CloudFileDirectory snapshotDir2 = new CloudFileDirectory(uriBuilder.addToURI(dir.getUri()), this.share.getServiceClient().getCredentials()); assertEquals(snapshot.snapshotID, snapshotDir2.getShare().snapshotID); assertTrue(snapshotDir2.exists());
CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials()); assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID); assertTrue(snapshotFile2.exists());
/** * Tests the CloudFileDirectory constructor. * * @throws URISyntaxException * @throws StorageException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class, CloudTests.class }) public void testCloudFileDirectoryConstructor() throws URISyntaxException, StorageException { CloudFileDirectory directory = this.share.getRootDirectoryReference().getDirectoryReference("directory1"); CloudFileDirectory directory2 = new CloudFileDirectory(directory.getStorageUri(), this.share.getServiceClient().getCredentials()); assertEquals(directory.getName(), directory2.getName()); assertEquals(directory.getStorageUri(), directory2.getStorageUri()); assertEquals(directory.getShare().getStorageUri(), directory2.getShare().getStorageUri()); assertEquals(FileTestHelper.ensureTrailingSlash(directory.getServiceClient().getStorageUri()), FileTestHelper.ensureTrailingSlash(directory2.getServiceClient().getStorageUri())); }