本文整理汇总了Java中com.microsoft.azure.storage.file.CloudFileClient类的典型用法代码示例。如果您正苦于以下问题:Java CloudFileClient类的具体用法?Java CloudFileClient怎么用?Java CloudFileClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudFileClient类属于com.microsoft.azure.storage.file包,在下文中一共展示了CloudFileClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AzureNotebookRepo
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
public AzureNotebookRepo(ZeppelinConfiguration conf)
throws URISyntaxException, InvalidKeyException, StorageException {
this.conf = conf;
user = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_USER);
shareName = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_SHARE);
CloudStorageAccount account = CloudStorageAccount.parse(
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING));
CloudFileClient client = account.createCloudFileClient();
CloudFileShare share = client.getShareReference(shareName);
share.createIfNotExists();
CloudFileDirectory userDir = StringUtils.isBlank(user) ?
share.getRootDirectoryReference() :
share.getRootDirectoryReference().getDirectoryReference(user);
userDir.createIfNotExists();
rootDir = userDir.getDirectoryReference("notebook");
rootDir.createIfNotExists();
}
示例2: createCloudFileClient
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
public static CloudFileClient createCloudFileClient(SharedAccessAccountPolicy policy, boolean useHttps)
throws StorageException, InvalidKeyException, URISyntaxException {
CloudStorageAccount sasAccount = getAccount();
final String token = sasAccount.generateSharedAccessSignature(policy);
final StorageCredentials creds =
new StorageCredentialsSharedAccessSignature(token);
final URI fileUri = new URI(useHttps ? "https" : "http", sasAccount.getFileEndpoint().getAuthority(),
sasAccount.getFileEndpoint().getPath(), sasAccount.getFileEndpoint().getQuery(), null);
sasAccount = new CloudStorageAccount(
creds, sasAccount.getBlobEndpoint(), sasAccount.getQueueEndpoint(), sasAccount.getTableEndpoint(),
fileUri);
return sasAccount.createCloudFileClient();
}
示例3: callUploadServiceProps
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
private void callUploadServiceProps(
ServiceClient client, ServiceProperties props, FileServiceProperties fileProps)
throws StorageException, InterruptedException {
if (client.getClass().equals(CloudBlobClient.class)) {
((CloudBlobClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudTableClient.class)) {
((CloudTableClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudQueueClient.class)) {
((CloudQueueClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudFileClient.class)) {
((CloudFileClient) client).uploadServiceProperties(fileProps);
}
else {
fail();
}
Thread.sleep(30000);
}
示例4: testCorsRules
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
/**
* Takes a CorsRule and tries to upload it. Then tries to download it and compares it to the initial CorsRule.
*/
private void testCorsRules(CorsRule rule, ServiceClient client, ServiceProperties properties,
FileServiceProperties fileServiceProperties) throws StorageException, InterruptedException {
CorsProperties cors = (fileServiceProperties == null) ? properties.getCors() : fileServiceProperties.getCors();
cors.getCorsRules().clear();
cors.getCorsRules().add(rule);
if (fileServiceProperties == null) {
callUploadServiceProps(client, properties, null);
assertServicePropertiesAreEqual(properties, callDownloadServiceProperties(client));
} else {
CloudFileClient fileClient = ((CloudFileClient) client);
fileClient.uploadServiceProperties(fileServiceProperties);
Thread.sleep(30000);
assertFileServicePropertiesAreEqual(fileServiceProperties, fileClient.downloadServiceProperties());
}
}
示例5: testCloudStorageAccountClientUriVerify
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
@Test
public void testCloudStorageAccountClientUriVerify() throws URISyntaxException, StorageException {
StorageCredentialsAccountAndKey cred = new StorageCredentialsAccountAndKey(ACCOUNT_NAME, ACCOUNT_KEY);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(cred, true);
CloudBlobClient blobClient = cloudStorageAccount.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference("container1");
assertEquals(cloudStorageAccount.getBlobEndpoint().toString() + "/container1", container.getUri().toString());
CloudQueueClient queueClient = cloudStorageAccount.createCloudQueueClient();
CloudQueue queue = queueClient.getQueueReference("queue1");
assertEquals(cloudStorageAccount.getQueueEndpoint().toString() + "/queue1", queue.getUri().toString());
CloudTableClient tableClient = cloudStorageAccount.createCloudTableClient();
CloudTable table = tableClient.getTableReference("table1");
assertEquals(cloudStorageAccount.getTableEndpoint().toString() + "/table1", table.getUri().toString());
CloudFileClient fileClient = cloudStorageAccount.createCloudFileClient();
CloudFileShare share = fileClient.getShareReference("share1");
assertEquals(cloudStorageAccount.getFileEndpoint().toString() + "/share1", share.getUri().toString());
}
示例6: createCloudFileClient
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
/**
* Creates a new File service client.
*
* @return A {@link CloudFileClient} that represents the cloud File client.
*
*/
public CloudFileClient createCloudFileClient() {
if (this.getFileStorageUri() == null) {
throw new IllegalArgumentException(SR.FILE_ENDPOINT_NOT_CONFIGURED);
}
if (this.credentials == null) {
throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
}
if (!StorageCredentialsHelper.canCredentialsGenerateClient(this.credentials)) {
throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
}
return new CloudFileClient(this.getFileStorageUri(), this.getCredentials());
}
示例7: callUploadServiceProps
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
private void callUploadServiceProps(
ServiceClient client, ServiceProperties props, FileServiceProperties fileProps)
throws StorageException, InterruptedException {
if (client.getClass().equals(CloudBlobClient.class)) {
((CloudBlobClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudTableClient.class)) {
((CloudTableClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudQueueClient.class)) {
((CloudQueueClient) client).uploadServiceProperties(props);
}
else if (client.getClass().equals(CloudFileClient.class)) {
((CloudFileClient) client).uploadServiceProperties(fileProps);
}
else {
fail();
}
// It may take up to 30 seconds for the settings to take effect, but the new properties are immediately
// visible when querying service properties.
}
示例8: testCorsRules
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
/**
* Takes a CorsRule and tries to upload it. Then tries to download it and compares it to the initial CorsRule.
*/
private void testCorsRules(CorsRule rule, ServiceClient client, ServiceProperties properties,
FileServiceProperties fileServiceProperties) throws StorageException, InterruptedException {
CorsProperties cors = (fileServiceProperties == null) ? properties.getCors() : fileServiceProperties.getCors();
cors.getCorsRules().clear();
cors.getCorsRules().add(rule);
if (fileServiceProperties == null) {
callUploadServiceProps(client, properties, null);
assertServicePropertiesAreEqual(properties, callDownloadServiceProperties(client));
} else {
CloudFileClient fileClient = ((CloudFileClient) client);
fileClient.uploadServiceProperties(fileServiceProperties);
assertFileServicePropertiesAreEqual(fileServiceProperties, fileClient.downloadServiceProperties());
}
}
示例9: createFileShareAsync
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
private Observable<Triple<String, String, String>> createFileShareAsync(final StorageAccount storageAccount) {
return storageAccount.getKeysAsync()
.map(new Func1<List<StorageAccountKey>, String>() {
@Override
public String call(List<StorageAccountKey> storageAccountKeys) {
return storageAccountKeys.get(0).value();
}
})
.flatMap(new Func1<String, Observable<Triple<String, String, String>>>() {
CloudFileClient cloudFileClient;
@Override
public Observable<Triple<String, String, String>> call(final String storageAccountKey) {
try {
cloudFileClient = CloudStorageAccount.parse(String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net",
storageAccount.name(),
storageAccountKey))
.createCloudFileClient();
} catch (URISyntaxException syntaxException) {
throw Exceptions.propagate(syntaxException);
} catch (InvalidKeyException keyException) {
throw Exceptions.propagate(keyException);
}
return Observable.from(newFileShares.entrySet())
.flatMap(new Func1<Map.Entry<String, String>, Observable<Triple<String, String, String>>>() {
@Override
public Observable<Triple<String, String, String>> call(Map.Entry<String, String> fileShareEntry) {
return createSingleFileShareAsync(cloudFileClient, fileShareEntry.getKey(), fileShareEntry.getValue(), storageAccountKey);
}
});
}
});
}
示例10: createSingleFileShareAsync
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
private Observable<Triple<String, String, String>> createSingleFileShareAsync(final CloudFileClient client, final String volumeName, final String fileShareName, final String storageAccountKey) {
return Observable.fromCallable(new Callable<Triple<String, String, String>>() {
@Override
public Triple<String, String, String> call() throws Exception {
CloudFileShare cloudFileShare = client.getShareReference(fileShareName);
cloudFileShare.createIfNotExists();
return Triple.of(volumeName, fileShareName, storageAccountKey);
}
});
}
示例11: createCloudFileClient
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
/**
* Creates a new File service client.
*
* @return A {@link CloudFileClient} that represents the cloud File client.
*
*/
public CloudFileClient createCloudFileClient() {
if (this.getFileStorageUri() == null) {
throw new IllegalArgumentException(SR.FILE_ENDPOINT_NOT_CONFIGURED);
}
if (this.credentials == null) {
throw new IllegalArgumentException(SR.MISSING_CREDENTIALS);
}
if (!StorageCredentialsHelper.canCredentialsSignRequest(this.credentials)) {
throw new IllegalArgumentException(SR.CREDENTIALS_CANNOT_SIGN_REQUEST);
}
return new CloudFileClient(this.getFileStorageUri(), this.getCredentials());
}
示例12: testFileMaximumExecutionTime
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
@Test
@Category({ DevFabricTests.class, DevStoreTests.class, SecondaryTests.class })
public void testFileMaximumExecutionTime() throws URISyntaxException, StorageException {
OperationContext opContext = new OperationContext();
setDelay(opContext, 2500);
opContext.getResponseReceivedEventHandler().addListener(new StorageEvent<ResponseReceivedEvent>() {
@Override
public void eventOccurred(ResponseReceivedEvent eventArg) {
// Set status code to 500 to force a retry
eventArg.getRequestResult().setStatusCode(500);
}
});
// set the maximum execution time
FileRequestOptions options = new FileRequestOptions();
options.setMaximumExecutionTimeInMs(2000);
options.setTimeoutIntervalInMs(1000);
CloudFileClient fileClient = TestHelper.createCloudFileClient();
CloudFileShare share = fileClient.getShareReference(generateRandomName("share"));
try {
// 1. download attributes will fail as the share does not exist
// 2. the executor will attempt to retry as we set the status code to 500
// 3. maximum execution time should prevent the retry from being made
share.downloadAttributes(null, options, opContext);
fail("Maximum execution time was reached but request did not fail.");
}
catch (StorageException e) {
assertEquals(SR.MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION, e.getMessage());
}
}
示例13: testCloudStorageAccountClientMethods
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
@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());
}
示例14: createCloudFileClient
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
public static CloudFileClient createCloudFileClient(SharedAccessAccountPolicy policy, boolean useHttps)
throws StorageException, InvalidKeyException, URISyntaxException {
CloudStorageAccount sasAccount = getAccount();
final String token = sasAccount.generateSharedAccessSignature(policy);
final StorageCredentials creds =
new StorageCredentialsSharedAccessSignature(token);
sasAccount = new CloudStorageAccount(
creds, sasAccount.getBlobEndpoint(), sasAccount.getQueueEndpoint(), sasAccount.getTableEndpoint(),
TestHelper.securePortUri(sasAccount.getFileEndpoint(), useHttps, 'f'));
return sasAccount.createCloudFileClient();
}
示例15: process
import com.microsoft.azure.storage.file.CloudFileClient; //导入依赖的package包/类
@RequestMapping(value = "/file", method = RequestMethod.GET)
public String process(HttpServletResponse response) {
LOG.info("FileRestController process start...");
StringBuffer result = new StringBuffer();
try {
result.append("Connecting to storage account..." + CR);
if (account == null)
{
account = factory.createAccountByServiceInstanceName("mystorage");
if (account == null)
{
String message = "CloudStorageAccount object not injected, lookup by name failed.";
LOG.error(message);
throw new RuntimeException(message);
}
}
result.append("Creating file client..." + CR);
CloudFileClient fileClient = account.createCloudFileClient();
result.append("Creating file share..." + CR);
CloudFileShare share = fileClient.getShareReference("productshare");
if (share.createIfNotExists()) {
result.append("Created file share..." + CR);
}
CloudFileDirectory rootDir = share.getRootDirectoryReference();
result.append("Creating products directory..." + CR);
CloudFileDirectory dir = rootDir.getDirectoryReference("products");
if (dir.createIfNotExists()) {
result.append("Created products directory..." + CR);
} else {
result.append("Products directory already exists..." + CR);
System.out.println("sampledir already exists");
}
result.append("Creating Product.txt file..." + CR);
CloudFile cloudFile = dir.getFileReference("Product.txt");
cloudFile.create(1024L);
cloudFile.openWriteExisting();
String contents = "PCF is a great product!";
result.append("Writing to file..." + CR);
InputStream in = new ByteArrayInputStream(contents.getBytes());
cloudFile.upload(in, contents.length());
result.append("Reading from file..." + CR);
String output = cloudFile.downloadText();
result.append("Contents = " + output + CR);
} catch (Exception e) {
LOG.error("Error processing request ", e);
}
result.append("Processed Date = " + new Date(System.currentTimeMillis()) + CR);
LOG.info("FileRestController process end");
return result.toString();
}
开发者ID:pivotal-partner-solution-architecture,项目名称:azure-service-broker-client,代码行数:64,代码来源:FileRestController.java