public List<String> emptyCloudBlobDirectory(final String containerName, final String virtualDirPath) throws StorageException, URISyntaxException { List<String> deletedFiles = new ArrayList<>(); CloudBlobContainer container = getCloudBlobContainer(containerName); for (ListBlobItem blobItem : container.listBlobs(virtualDirPath, true, null, null, null)) { CloudBlob cloudBlob = (CloudBlob) blobItem; log.info("Removing file[%s] from Azure.", cloudBlob.getName()); if (cloudBlob.deleteIfExists()) { deletedFiles.add(cloudBlob.getName()); } } if (deletedFiles.isEmpty()) { log.warn("No files were deleted on the following Azure path: [%s]", virtualDirPath); } return deletedFiles; }
AzureStorageUtils.setProxy(operationContext, context); for (ListBlobItem blob : container.listBlobs(prefix, true, EnumSet.of(BlobListingDetails.METADATA), null, operationContext)) { if (blob instanceof CloudBlob) { CloudBlob cloudBlob = (CloudBlob) blob;
@Override public void iterationInit(boolean deep) { if (iContainer == null) iter = iContainer.listBlobs().iterator(); }
/** * Returns an enumerable collection of blob items for the container. * * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the items in * this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() { return this.listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null); }
/** * Returns an enumerable collection of blob items for the container. * * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the items in * this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() { return this.listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null); }
/** * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix. * * @param prefix * A <code>String</code> that represents the blob name prefix. This value must be preceded either by the * name of the container or by the absolute path to the container. * * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the * items whose names begin with the specified prefix in this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(final String prefix) { return this.listBlobs(prefix, false); }
/** * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix. * * @param prefix * A <code>String</code> that represents the blob name prefix. This value must be preceded either by the * name of the container or by the absolute path to the container. * * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the * items whose names begin with the specified prefix in this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(final String prefix) { return this.listBlobs(prefix, false); }
/** * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix * using the specified flat or hierarchical option. * * @param prefix * A <code>String</code> that represents the blob name prefix. This value must be preceded either by the * name of the container or by the absolute path to the container. * @param useFlatBlobListing * <code>true</code> to indicate that the returned list will be flat; <code>false</code> to indicate that * the returned list will be hierarchical. * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the * items whose names begin with the specified prefix in this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(final String prefix, final boolean useFlatBlobListing) { return this.listBlobs(prefix, useFlatBlobListing, EnumSet.noneOf(BlobListingDetails.class), null, null); }
/** * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix * using the specified flat or hierarchical option. * * @param prefix * A <code>String</code> that represents the blob name prefix. This value must be preceded either by the * name of the container or by the absolute path to the container. * @param useFlatBlobListing * <code>true</code> to indicate that the returned list will be flat; <code>false</code> to indicate that * the returned list will be hierarchical. * @return An enumerable collection of {@link ListBlobItem} objects retrieved lazily that represents the * items whose names begin with the specified prefix in this container. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(final String prefix, final boolean useFlatBlobListing) { return this.listBlobs(prefix, useFlatBlobListing, EnumSet.noneOf(BlobListingDetails.class), null, null); }
private Map<String, Long> getSnapshotFileKeys(CloudBlobContainer container, String keyPrefix) { Map<String, Long> snapshotFiles = new HashMap<>(); try { for (ListBlobItem item : container.listBlobs(keyPrefix, true)) { if (item instanceof CloudPageBlob) { CloudPageBlob cloudBlob = (CloudPageBlob) item; snapshotFiles.put(cloudBlob.getName(), getOriginalFileSize(cloudBlob)); } } } catch (StorageException e) { logger.error("Unable to retrieve metadata.", e); // all or none snapshotFiles = new HashMap<>(); } return snapshotFiles; }
@NotNull public static String listBlobs(@NotNull final StorageInputs inputs) throws Exception { final CloudBlobClient blobClient = getCloudBlobClient(inputs); final CloudBlobContainer container = blobClient.getContainerReference(inputs.getContainerName()); final List<String> blobList = new ArrayList<>(); for (final ListBlobItem blobItem : container.listBlobs()) { final String path = blobItem.getUri().getPath(); blobList.add(path.substring(path.lastIndexOf(FORWARD_SLASH) + 1)); } return StringUtilities.join(blobList, COMMA); }
protected void deleteBlobDir(CloudBlobContainer container, String path) throws StorageException { for (ListBlobItem blobItem : container.listBlobs(path)) { if (blobItem instanceof CloudBlockBlob) { ((CloudBlockBlob)blobItem).deleteIfExists(); } else { String subdir = blobItem.getUri().getPath().replaceAll("^/[^/]*?/", ""); deleteBlobDir(container, subdir); } } }
public Iterable<ListBlobItem> listBlobs(final String containerName, final String prefix, final boolean useFlatBlobListing) throws URISyntaxException, StorageException, InvalidKeyException { CloudBlobClient cloudBlobClient = connection.getCloudStorageAccount().createCloudBlobClient(); CloudBlobContainer cloudBlobContainer = cloudBlobClient.getContainerReference(containerName); return cloudBlobContainer.listBlobs(prefix, useFlatBlobListing, EnumSet.noneOf(BlobListingDetails.class), null, AzureStorageUtils.getTalendOperationContext()); }
/** * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. * * @param prefix * A <code>String</code> that represents the blob name prefix. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin * with the specified prefix in this directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(String prefix) throws URISyntaxException, StorageException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); }
public Iterable<ListBlobItem> listBlobs(final String containerName, final String prefix, final boolean useFlatBlobListing) throws URISyntaxException, StorageException, InvalidKeyException { CloudBlobClient cloudBlobClient = connection.getCloudStorageAccount().createCloudBlobClient(); CloudBlobContainer cloudBlobContainer = cloudBlobClient.getContainerReference(containerName); return cloudBlobContainer.listBlobs(prefix, useFlatBlobListing, EnumSet.noneOf(BlobListingDetails.class), null, AzureStorageUtils.getTalendOperationContext()); }
/** * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. * * @param prefix * A <code>String</code> that represents the blob name prefix. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin * with the specified prefix in this directory. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs(String prefix) throws URISyntaxException, StorageException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); }
/** * Returns an enumerable collection of blob items for the directory. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this * container. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() throws StorageException, URISyntaxException { return this.getContainer().listBlobs(this.getPrefix()); }
/** * Returns an enumerable collection of blob items for the directory. * * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this * container. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest public Iterable<ListBlobItem> listBlobs() throws StorageException, URISyntaxException { return this.getContainer().listBlobs(this.getPrefix()); }
public List<String> emptyCloudBlobDirectory(final String containerName, final String virtualDirPath) throws StorageException, URISyntaxException { List<String> deletedFiles = new ArrayList<>(); CloudBlobContainer container = getCloudBlobContainer(containerName); for (ListBlobItem blobItem : container.listBlobs(virtualDirPath, true, null, null, null)) { CloudBlob cloudBlob = (CloudBlob) blobItem; log.info("Removing file[%s] from Azure.", cloudBlob.getName()); if (cloudBlob.deleteIfExists()) { deletedFiles.add(cloudBlob.getName()); } } if (deletedFiles.isEmpty()) { log.warn("No files were deleted on the following Azure path: [%s]", virtualDirPath); } return deletedFiles; }
@Test public void testListBlobsEncryption() throws URISyntaxException, StorageException, IOException { boolean blobFound = false; for (ListBlobItem b : this.container.listBlobs()) { CloudBlob blob = (CloudBlob) b; assertTrue(blob.getProperties().isServerEncrypted()); blobFound = true; } assertTrue(blobFound); }