本文整理汇总了Java中com.microsoft.azure.storage.blob.SharedAccessBlobPermissions类的典型用法代码示例。如果您正苦于以下问题:Java SharedAccessBlobPermissions类的具体用法?Java SharedAccessBlobPermissions怎么用?Java SharedAccessBlobPermissions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharedAccessBlobPermissions类属于com.microsoft.azure.storage.blob包,在下文中一共展示了SharedAccessBlobPermissions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPolicy
import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; //导入依赖的package包/类
private SharedAccessBlobPolicy getPolicy(final int expiry) {
final SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
policy.setSharedAccessExpiryTime(new Date(this.getExpiry(expiry)));
policy.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ));
return policy;
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:7,代码来源:AzureUrlProvider.java
示例2: generateSAS
import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; //导入依赖的package包/类
private static String generateSAS(CloudBlobContainer container,
boolean readonly) throws Exception {
// Create a container if it does not exist.
container.createIfNotExists();
// Create a new shared access policy.
SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy();
// Create a UTC Gregorian calendar value.
GregorianCalendar calendar = new GregorianCalendar(
TimeZone.getTimeZone("UTC"));
// Specify the current time as the start time for the shared access
// signature.
//
calendar.setTime(new Date());
sasPolicy.setSharedAccessStartTime(calendar.getTime());
// Use the start time delta one hour as the end time for the shared
// access signature.
calendar.add(Calendar.HOUR, 10);
sasPolicy.setSharedAccessExpiryTime(calendar.getTime());
if (readonly) {
// Set READ permissions
sasPolicy.setPermissions(EnumSet.of(
SharedAccessBlobPermissions.READ,
SharedAccessBlobPermissions.LIST));
} else {
// Set READ and WRITE permissions.
//
sasPolicy.setPermissions(EnumSet.of(
SharedAccessBlobPermissions.READ,
SharedAccessBlobPermissions.WRITE,
SharedAccessBlobPermissions.LIST));
}
// Create the container permissions.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Turn public access to the container off.
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.OFF);
container.uploadPermissions(containerPermissions);
// Create a shared access signature for the container.
String sas = container.generateSharedAccessSignature(sasPolicy, null);
// HACK: when the just generated SAS is used straight away, we get an
// authorization error intermittently. Sleeping for 1.5 seconds fixes that
// on my box.
Thread.sleep(1500);
// Return to caller with the shared access signature.
return sas;
}
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:AzureBlobStorageTestAccount.java
示例3: primePublicContainer
import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; //导入依赖的package包/类
public static void primePublicContainer(CloudBlobClient blobClient,
String accountName, String containerName, String blobName, int fileSize)
throws Exception {
// Create a container if it does not exist. The container name
// must be lower case.
CloudBlobContainer container = blobClient
.getContainerReference(containerName);
container.createIfNotExists();
// Create a new shared access policy.
SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy();
// Set READ and WRITE permissions.
//
sasPolicy.setPermissions(EnumSet.of(
SharedAccessBlobPermissions.READ,
SharedAccessBlobPermissions.WRITE,
SharedAccessBlobPermissions.LIST,
SharedAccessBlobPermissions.DELETE));
// Create the container permissions.
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Turn public access to the container off.
containerPermissions
.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the policy using the values set above.
containerPermissions.getSharedAccessPolicies().put("testwasbpolicy",
sasPolicy);
container.uploadPermissions(containerPermissions);
// Create a blob output stream.
CloudBlockBlob blob = container.getBlockBlobReference(blobName);
BlobOutputStream outputStream = blob.openOutputStream();
outputStream.write(new byte[fileSize]);
outputStream.close();
}
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:AzureBlobStorageTestAccount.java
示例4: setup
import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; //导入依赖的package包/类
@PostConfig
@PostCreated
@PostRecovery
public void setup()
{
_serviceBaseURL = _properties.get(SERVICEBASEURL_PROPERTYNAME);
_containerName = _properties.get(CONTAINERNAME_PROPERTYNAME);
_storageConnection = _properties.get(STORAGECONNECTION_PROPERTYNAME);
_accountName = _properties.get(ACCOUNTNAME_PROPERTYNAME);
_accountKey = _properties.get(ACCOUNTKEY_PROPERTYNAME);
_containerSAS = _properties.get(CONTAINERSAS_PROPERTYNAME);
if ((_containerSAS == null) || "".equals(_containerSAS.trim()))
{
String storageConnection = null;
if ((_storageConnection != null) && (! "".equals(_storageConnection.trim())))
storageConnection = _storageConnection;
else if ((_accountName != null) && (! "".equals(_accountName.trim())) && (_accountKey != null) && (! "".equals(_accountKey.trim())))
storageConnection = "DefaultEndpointsProtocol=https;AccountName=" + _accountName + ";AccountKey=" + _accountKey;
if (storageConnection != null)
{
try
{
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnection);
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.getContainerReference(_containerName);
blobContainer.createIfNotExists();
SharedAccessBlobPolicy blobPolicy = new SharedAccessBlobPolicy();
GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
calendar.setTime(new Date());
blobPolicy.setSharedAccessStartTime(calendar.getTime());
calendar.add(Calendar.HOUR, 6);
blobPolicy.setSharedAccessExpiryTime(calendar.getTime());
blobPolicy.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ, SharedAccessBlobPermissions.WRITE));
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.OFF);
containerPermissions.getSharedAccessPolicies().put("accesspolicy", blobPolicy);
blobContainer.uploadPermissions(containerPermissions);
_containerSAS = blobContainer.generateSharedAccessSignature(blobPolicy, null);
}
catch (Throwable throwable)
{
logger.log(Level.WARNING, "Problems with Azure blob store SAS", throwable);
}
}
}
}
开发者ID:arjuna-technologies,项目名称:Azure_DataBroker_PlugIn,代码行数:52,代码来源:AzureStorageDataService.java
示例5: doCloudBlobCopy
import com.microsoft.azure.storage.blob.SharedAccessBlobPermissions; //导入依赖的package包/类
private CloudFile doCloudBlobCopy(CloudBlob source, int length) throws Exception {
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
cal.setTime(new Date());
cal.add(Calendar.MINUTE, 5);
// Source SAS must have read permissions
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
policy.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ));
policy.setSharedAccessExpiryTime(cal.getTime());
String sasToken = source.generateSharedAccessSignature(policy, null, null);
// Get destination reference
final CloudFile destination = this.share.getRootDirectoryReference().getFileReference("destination");
// Start copy and wait for completion
StorageCredentialsSharedAccessSignature credentials = new StorageCredentialsSharedAccessSignature(sasToken);
Constructor<? extends CloudBlob> blobType = source.getClass().getConstructor(URI.class);
String copyId = destination.startCopy(blobType.newInstance(credentials.transformUri(source.getUri())));
FileTestHelper.waitForCopy(destination);
destination.downloadAttributes();
// Check original file references for equality
assertEquals(CopyStatus.SUCCESS, destination.getCopyState().getStatus());
assertEquals(source.getServiceClient().getCredentials().transformUri(source.getUri()).getPath(),
destination.getCopyState().getSource().getPath());
assertEquals(length, destination.getCopyState().getTotalBytes().intValue());
assertEquals(length, destination.getCopyState().getBytesCopied().intValue());
assertEquals(copyId, destination.getProperties().getCopyState().getCopyId());
// Attempt to abort the completed copy operation.
try {
destination.abortCopy(destination.getCopyState().getCopyId());
FileTestHelper.waitForCopy(destination);
fail();
}
catch (StorageException ex) {
assertEquals(HttpURLConnection.HTTP_CONFLICT, ex.getHttpStatusCode());
}
assertNotNull(destination.getProperties().getEtag());
assertFalse(source.getProperties().getEtag().equals(destination.getProperties().getEtag()));
source.downloadAttributes();
FileProperties prop1 = destination.getProperties();
BlobProperties prop2 = source.getProperties();
assertEquals(prop1.getCacheControl(), prop2.getCacheControl());
assertEquals(prop1.getContentEncoding(), prop2.getContentEncoding());
assertEquals(prop1.getContentLanguage(), prop2.getContentLanguage());
assertEquals(prop1.getContentMD5(), prop2.getContentMD5());
assertEquals(prop1.getContentType(), prop2.getContentType());
assertEquals("value", destination.getMetadata().get("Test"));
return destination;
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:57,代码来源:CloudFileTests.java
注:本文中的com.microsoft.azure.storage.blob.SharedAccessBlobPermissions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论