本文整理汇总了Java中com.microsoft.azure.storage.blob.BlobProperties类的典型用法代码示例。如果您正苦于以下问题:Java BlobProperties类的具体用法?Java BlobProperties怎么用?Java BlobProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlobProperties类属于com.microsoft.azure.storage.blob包,在下文中一共展示了BlobProperties类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: listBlobsByPrefix
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
@Override
public Map<String, BlobMetaData> listBlobsByPrefix(String account, LocationMode mode, String container, String keyPath, String prefix) throws URISyntaxException, StorageException {
// NOTE: this should be here: if (prefix == null) prefix = "";
// however, this is really inefficient since deleteBlobsByPrefix enumerates everything and
// then does a prefix match on the result; it should just call listBlobsByPrefix with the prefix!
logger.debug("listing container [{}], keyPath [{}], prefix [{}]", container, keyPath, prefix);
MapBuilder<String, BlobMetaData> blobsBuilder = MapBuilder.newMapBuilder();
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blobContainer = client.getContainerReference(container);
SocketAccess.doPrivilegedVoidException(() -> {
if (blobContainer.exists()) {
for (ListBlobItem blobItem : blobContainer.listBlobs(keyPath + (prefix == null ? "" : prefix))) {
URI uri = blobItem.getUri();
logger.trace("blob url [{}]", uri);
// uri.getPath is of the form /container/keyPath.* and we want to strip off the /container/
// this requires 1 + container.length() + 1, with each 1 corresponding to one of the /
String blobPath = uri.getPath().substring(1 + container.length() + 1);
CloudBlockBlob blob = blobContainer.getBlockBlobReference(blobPath);
// fetch the blob attributes from Azure (getBlockBlobReference does not do this)
// this is needed to retrieve the blob length (among other metadata) from Azure Storage
blob.downloadAttributes();
BlobProperties properties = blob.getProperties();
String name = blobPath.substring(keyPath.length());
logger.trace("blob url [{}], name [{}], size [{}]", uri, name, properties.getLength());
blobsBuilder.put(name, new PlainBlobMetaData(name, properties.getLength()));
}
}
});
return blobsBuilder.immutableMap();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:AzureStorageServiceImpl.java
示例2: getDataLength
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
/**
* Return the actual data length of the blob with the specified properties.
* If it is a page blob, you can't rely on the length from the properties
* argument and you must get it from the file. Otherwise, you can.
*/
private long getDataLength(CloudBlobWrapper blob, BlobProperties properties)
throws AzureException {
if (blob instanceof CloudPageBlobWrapper) {
try {
return PageBlobInputStream.getPageBlobSize((CloudPageBlobWrapper) blob,
getInstrumentedContext(
isConcurrentOOBAppendAllowed()));
} catch (Exception e) {
throw new AzureException(
"Unexpected exception getting page blob actual data size.", e);
}
}
return properties.getLength();
}
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:AzureNativeFileSystemStore.java
示例3: MockCloudBlobWrapper
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
protected MockCloudBlobWrapper(URI uri, HashMap<String, String> metadata,
int length) {
this.uri = uri;
this.metadata = metadata;
this.properties = new BlobProperties();
this.properties=updateLastModifed(this.properties);
this.properties=updateLength(this.properties,length);
}
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:MockStorageInterface.java
示例4: updateLastModifed
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
protected BlobProperties updateLastModifed(BlobProperties properties){
try{
Method setLastModified =properties.getClass().
getDeclaredMethod("setLastModified", Date.class);
setLastModified.setAccessible(true);
setLastModified.invoke(this.properties,
Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTime());
}catch(Exception e){
throw new RuntimeException(e);
}
return properties;
}
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:MockStorageInterface.java
示例5: updateLength
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
protected BlobProperties updateLength(BlobProperties properties,int length) {
try{
Method setLength =properties.getClass().
getDeclaredMethod("setLength", long.class);
setLength.setAccessible(true);
setLength.invoke(this.properties, length);
}catch (Exception e){
throw new RuntimeException(e);
}
return properties;
}
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:MockStorageInterface.java
示例6: refreshProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
protected void refreshProperties(boolean getMetadata) {
if (backingStore.exists(convertUriToDecodedString(uri))) {
byte[] content = backingStore.getContent(convertUriToDecodedString(uri));
properties = new BlobProperties();
this.properties=updateLastModifed(this.properties);
this.properties=updateLength(this.properties, content.length);
if (getMetadata) {
metadata = backingStore.getMetadata(convertUriToDecodedString(uri));
}
}
}
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:MockStorageInterface.java
示例7: getDataLength
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
/**
* Return the actual data length of the blob with the specified properties.
* If it is a page blob, you can't rely on the length from the properties
* argument and you must get it from the file. Otherwise, you can.
*/
private long getDataLength(CloudBlobWrapper blob, BlobProperties properties)
throws AzureException {
if (blob instanceof CloudPageBlobWrapper) {
try {
return PageBlobInputStream.getPageBlobDataSize((CloudPageBlobWrapper) blob,
getInstrumentedContext(
isConcurrentOOBAppendAllowed()));
} catch (Exception e) {
throw new AzureException(
"Unexpected exception getting page blob actual data size.", e);
}
}
return properties.getLength();
}
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:AzureNativeFileSystemStore.java
示例8: createFromAzureListBlobItem
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
/**
* Contructs a StorageObjectSummary object from Azure BLOB properties
* Using factory methods to create these objects since Azure can throw,
* while retrieving the BLOB properties
* @param listBlobItem an Azure ListBlobItem object
* @return the ObjectSummary object created
*/
public static StorageObjectSummary createFromAzureListBlobItem(ListBlobItem listBlobItem)
throws StorageProviderException
{
String location, key, md5;
long size;
// Retrieve the BLOB properties that we need for the Summary
// Azure Storage stores metadata inside each BLOB, therefore the listBlobItem
// will point us to the underlying BLOB and will get the properties from it
// During the process the Storage Client could fail, hence we need to wrap the
// get calls in try/catch and handle possible exceptions
try
{
location = listBlobItem.getContainer().getName();
CloudBlob cloudBlob = (CloudBlob) listBlobItem;
key = cloudBlob.getName();
BlobProperties blobProperties = cloudBlob.getProperties();
// the content md5 property is not always the actual md5 of the file. But for here, it's only
// used for skipping file on PUT command, hense is ok.
md5 = convertBase64ToHex(blobProperties.getContentMD5());
size = blobProperties.getLength();
}
catch (URISyntaxException | StorageException ex)
{
// This should only happen if somehow we got here with and invalid URI (it should never happen)
// ...or there is a Storage service error. Unlike S3, Azure fetches metadata from the BLOB itself,
// and its a lazy operation
throw new StorageProviderException(ex);
}
return new StorageObjectSummary(location, key, md5, size);
}
开发者ID:snowflakedb,项目名称:snowflake-jdbc,代码行数:42,代码来源:StorageObjectSummary.java
示例9: getConfigBlobProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
private BlobProperties getConfigBlobProperties() throws Exception {
try {
BlobProperties properties = azureClient.getBlobProperties(arguments.getContainer(), arguments.getBlobName());
if (properties.getLength() > 0) {
return properties;
}
} catch (StorageException e) {
if (!isNotFoundError(e) && !isForbiddenError(e)) {
throw e;
}
}
return null;
}
开发者ID:dcos,项目名称:exhibitor,代码行数:14,代码来源:AzureConfigProvider.java
示例10: getProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
@Override
public BlobProperties getProperties() {
return getBlob().getProperties();
}
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:StorageInterfaceImpl.java
示例11: getProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
@Override
public BlobProperties getProperties() {
return properties;
}
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:MockStorageInterface.java
示例12: doCloudBlobCopy
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的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
示例13: testFileCopyFromBlobWithSasAndSnapshot
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
@Test
public void testFileCopyFromBlobWithSasAndSnapshot()
throws URISyntaxException, StorageException, InterruptedException, IOException, InvalidKeyException {
String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob");
CloudBlobContainer container = TestHelper.createCloudBlobClient().getContainerReference(BlobTestHelper.generateRandomContainerName());
container.createIfNotExists();
CloudBlockBlob source = container.getBlockBlobReference(blobName);
String data = "String data";
source.uploadText(data, Constants.UTF8_CHARSET, null, null, null);
byte[] buffer = BlobTestHelper.getRandomBuffer(512);
ByteArrayInputStream stream = new ByteArrayInputStream(buffer);
source.upload(stream, buffer.length);
source.getMetadata().put("Test", "value");
source.uploadMetadata();
SharedAccessFilePolicy policy = createSharedAccessPolicy(
EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.WRITE,
SharedAccessFilePermissions.LIST, SharedAccessFilePermissions.DELETE), 5000);
CloudFile copy = this.share.getRootDirectoryReference().getFileReference("copy");
String sasToken = copy.generateSharedAccessSignature(policy, null);
CloudFile copySas = new CloudFile(new URI(copy.getUri().toString() + "?" + sasToken));
// Generate account SAS for the source
// Cannot generate a SAS directly on a snapshot and the SAS for the destination is only for the destination
SharedAccessAccountPolicy accountPolicy = new SharedAccessAccountPolicy();
accountPolicy.setPermissions(EnumSet.of(SharedAccessAccountPermissions.READ, SharedAccessAccountPermissions.WRITE));
accountPolicy.setServices(EnumSet.of(SharedAccessAccountService.BLOB));
accountPolicy.setResourceTypes(EnumSet.of(SharedAccessAccountResourceType.OBJECT, SharedAccessAccountResourceType.CONTAINER));
accountPolicy.setSharedAccessExpiryTime(policy.getSharedAccessExpiryTime());
final CloudBlobClient sasClient = TestHelper.createCloudBlobClient(accountPolicy, false);
CloudBlockBlob snapshot = (CloudBlockBlob) source.createSnapshot();
CloudBlockBlob sasBlob = (CloudBlockBlob) sasClient.getContainerReference(container.getName())
.getBlobReferenceFromServer(snapshot.getName(), snapshot.getSnapshotID(), null, null, null);
sasBlob.exists();
String copyId = copySas.startCopy(BlobTestHelper.defiddler(sasBlob));
FileTestHelper.waitForCopy(copySas);
copySas.downloadAttributes();
FileProperties prop1 = copySas.getProperties();
BlobProperties prop2 = sasBlob.getProperties();
assertEquals(prop1.getCacheControl(), prop2.getCacheControl());
assertEquals(prop1.getContentEncoding(), prop2.getContentEncoding());
assertEquals(prop1.getContentDisposition(),
prop2.getContentDisposition());
assertEquals(prop1.getContentLanguage(), prop2.getContentLanguage());
assertEquals(prop1.getContentMD5(), prop2.getContentMD5());
assertEquals(prop1.getContentType(), prop2.getContentType());
assertEquals("value", copySas.getMetadata().get("Test"));
assertEquals(copyId, copySas.getCopyState().getCopyId());
snapshot.delete();
source.delete();
copySas.delete();
container.delete();
}
开发者ID:Azure,项目名称:azure-storage-android,代码行数:62,代码来源:FileSasTests.java
示例14: getObjectMetadata
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
private BlobProperties getObjectMetadata(CloudBlob object) {
BlobProperties metadata = null;
if (object != null) {
metadata = object.getProperties();
}
return metadata;
}
开发者ID:EisenVault,项目名称:ev-alfresco-azure-adapter,代码行数:12,代码来源:AzureContentReader.java
示例15: getProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
/**
* Returns the blob's properties.
*
* @return A {@link BlobProperties} object that represents the properties of
* the blob.
*/
BlobProperties getProperties();
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:StorageInterface.java
示例16: getBlobProperties
import com.microsoft.azure.storage.blob.BlobProperties; //导入依赖的package包/类
public BlobProperties getBlobProperties(String containerName, String uri) throws Exception;
开发者ID:dcos,项目名称:exhibitor,代码行数:2,代码来源:AzureClient.java
注:本文中的com.microsoft.azure.storage.blob.BlobProperties类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论