storage account report
This commit is contained in:
@@ -1693,3 +1693,45 @@ export const listBlobHierarchical = async (
|
||||
}
|
||||
}
|
||||
};
|
||||
export async function listBlobHierarchicalForUser(containerClient) {
|
||||
const blobNames = [];
|
||||
for await (const blob of containerClient.listBlobsFlat()) {
|
||||
blobNames.push(blob.name);
|
||||
}
|
||||
return blobNames;
|
||||
}
|
||||
|
||||
export async function listContainersForUser(
|
||||
blobServiceClient,
|
||||
containerNamePrefix,
|
||||
emailAddress
|
||||
) {
|
||||
const options = {
|
||||
includeDeleted: false,
|
||||
includeMetadata: true,
|
||||
includeSystem: true,
|
||||
prefix: containerNamePrefix,
|
||||
};
|
||||
|
||||
const results = [];
|
||||
|
||||
for await (const containerItem of blobServiceClient.listContainers(
|
||||
options
|
||||
)) {
|
||||
const containerClient = blobServiceClient.getContainerClient(
|
||||
containerItem.name
|
||||
);
|
||||
const blobNames = await listBlobHierarchicalForUser(
|
||||
containerClient
|
||||
).catch(console.error);
|
||||
|
||||
if (blobNames && blobNames.length > 0) {
|
||||
results.push({
|
||||
container: containerItem.name,
|
||||
blobs: blobNames,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results; // array of non-empty containers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user