Utility.assertNotNull("shareName", shareName); this.storageUri = PathUtility.appendPathToUri(client.getStorageUri(), shareName); this.name = shareName; this.snapshotID = snapshotID;
Utility.assertNotNull("shareName", shareName); this.storageUri = PathUtility.appendPathToUri(client.getStorageUri(), shareName); this.name = shareName; this.snapshotID = snapshotID;
options, this.getStorageUri()) {
options, this.getStorageUri()) {
@Override public HttpURLConnection buildRequest(CloudFileClient client, Void parentObject, OperationContext context) throws Exception { listingContext.setMarker(segmentedRequest.getToken() != null ? segmentedRequest.getToken() .getNextMarker() : null); return FileRequest.listShares( client.getCredentials().transformUri(client.getStorageUri()).getUri(this.getCurrentLocation()), options, context, listingContext, detailsIncluded); }
@Override public HttpURLConnection buildRequest(CloudFileClient client, Void parentObject, OperationContext context) throws Exception { listingContext.setMarker(segmentedRequest.getToken() != null ? segmentedRequest.getToken() .getNextMarker() : null); return FileRequest.listShares( client.getCredentials().transformUri(client.getStorageUri()).getUri(this.getCurrentLocation()), options, context, listingContext, detailsIncluded); }
@Test public void testFileSAS() throws InvalidKeyException, IllegalArgumentException, StorageException, URISyntaxException, InterruptedException { SharedAccessFilePolicy policy = createSharedAccessPolicy( EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.LIST), 300); FileSharePermissions perms = new FileSharePermissions(); perms.getSharedAccessPolicies().put("readperm", policy); this.share.uploadPermissions(perms); Thread.sleep(30000); CloudFile sasFile = new CloudFile( new URI(this.file.getUri().toString() + "?" + this.file.generateSharedAccessSignature(null, "readperm"))); sasFile.download(new ByteArrayOutputStream()); // do not give the client and check that the new file's client has the correct permissions CloudFile fileFromUri = new CloudFile(PathUtility.addToQuery(this.file.getStorageUri(), this.file.generateSharedAccessSignature(null, "readperm"))); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), fileFromUri.getServiceClient().getCredentials().getClass().toString()); // create credentials from sas StorageCredentials creds = new StorageCredentialsSharedAccessSignature( this.file.generateSharedAccessSignature(policy, null, null)); CloudFileClient client = new CloudFileClient(sasFile.getServiceClient().getStorageUri(), creds); CloudFile fileFromClient = client.getShareReference(this.file.getShare().getName()).getRootDirectoryReference() .getFileReference(this.file.getName()); assertEquals(StorageCredentialsSharedAccessSignature.class.toString(), fileFromClient.getServiceClient().getCredentials().getClass().toString()); assertEquals(client, fileFromClient.getServiceClient()); }
CloudFileClient client = new CloudFileClient(this.share.getServiceClient().getStorageUri(), creds);
/** * Test file constructor. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileConstructor() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); CloudFile file2 = new CloudFile(file.getStorageUri(), file.getServiceClient().getCredentials()); assertEquals(file.getName(), file2.getName()); assertEquals(file.getStorageUri(), file2.getStorageUri()); assertEquals(file.getShare().getStorageUri(), file2.getShare().getStorageUri()); assertEquals(FileTestHelper.ensureTrailingSlash(file.getServiceClient().getStorageUri()), FileTestHelper.ensureTrailingSlash(file2.getServiceClient().getStorageUri())); CloudFile file3 = new CloudFile(file2); assertEquals(file3.getName(), file2.getName()); assertEquals(file3.getStorageUri(), file2.getStorageUri()); assertEquals(file3.getShare().getStorageUri(), file2.getShare().getStorageUri()); assertEquals(FileTestHelper.ensureTrailingSlash(file3.getServiceClient().getStorageUri()), FileTestHelper.ensureTrailingSlash(file2.getServiceClient().getStorageUri())); }
/** * 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())); }
@Test public void testCloudStorageAccountClientMethods() throws URISyntaxException { StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY); CloudStorageAccount account = new CloudStorageAccount(cred, false); CloudBlobClient blob = account.createCloudBlobClient(); CloudQueueClient queue = account.createCloudQueueClient(); CloudTableClient table = account.createCloudTableClient(); CloudFileClient file = account.createCloudFileClient(); // check endpoints assertEquals("Blob endpoint doesn't match account", account.getBlobEndpoint(), blob.getEndpoint()); assertEquals("Queue endpoint doesn't match account", account.getQueueEndpoint(), queue.getEndpoint()); assertEquals("Table endpoint doesn't match account", account.getTableEndpoint(), table.getEndpoint()); assertEquals("File endpoint doesn't match account", account.getFileEndpoint(), file.getEndpoint()); // check storage uris assertEquals("Blob endpoint doesn't match account", account.getBlobStorageUri(), blob.getStorageUri()); assertEquals("Queue endpoint doesn't match account", account.getQueueStorageUri(), queue.getStorageUri()); assertEquals("Table endpoint doesn't match account", account.getTableStorageUri(), table.getStorageUri()); assertEquals("File endpoint doesn't match account", account.getFileStorageUri(), file.getStorageUri()); // check creds assertEquals("Blob creds don't match account", account.getCredentials(), blob.getCredentials()); assertEquals("Queue creds don't match account", account.getCredentials(), queue.getCredentials()); assertEquals("Table creds don't match account", account.getCredentials(), table.getCredentials()); assertEquals("File creds don't match account", account.getCredentials(), file.getCredentials()); }