in src/blob/handlers/ContainerHandler.ts [732:829]
public async listBlobHierarchySegment(
delimiter: string,
options: Models.ContainerListBlobHierarchySegmentOptionalParams,
context: Context
): Promise<Models.ContainerListBlobHierarchySegmentResponse> {
// TODO: Need update list out blobs lease properties with BlobHandler.updateLeaseAttributes()
const blobCtx = new BlobStorageContext(context);
const accountName = blobCtx.account!;
const containerName = blobCtx.container!;
await this.metadataStore.checkContainerExist(
context,
accountName,
containerName
);
const request = context.request!;
const marker = options.marker;
options.prefix = options.prefix || "";
options.marker = options.marker || "";
let includeSnapshots: boolean = false;
let includeUncommittedBlobs: boolean = false;
let includeTags: boolean = false;
let includeMetadata: boolean = false;
if (options.include !== undefined) {
options.include.forEach(element => {
if (Models.ListBlobsIncludeItem.Snapshots.toLowerCase() === element.toLowerCase()) {
includeSnapshots = true;
}
if (Models.ListBlobsIncludeItem.Uncommittedblobs.toLowerCase() === element.toLowerCase()) {
includeUncommittedBlobs = true;
}
if (Models.ListBlobsIncludeItem.Tags.toLowerCase() === element.toLowerCase()) {
includeTags = true;
}
if (Models.ListBlobsIncludeItem.Metadata.toLowerCase() === element.toLowerCase()) {
includeMetadata = true;
}
}
)
}
if (
options.maxresults === undefined ||
options.maxresults > DEFAULT_LIST_BLOBS_MAX_RESULTS
) {
options.maxresults = DEFAULT_LIST_BLOBS_MAX_RESULTS;
}
const [blobItems, blobPrefixes, nextMarker] = await this.metadataStore.listBlobs(
context,
accountName,
containerName,
delimiter === "" ? undefined : delimiter,
undefined,
options.prefix,
options.maxresults,
marker,
includeSnapshots,
includeUncommittedBlobs
);
const serviceEndpoint = `${request.getEndpoint()}/${accountName}`;
const response: Models.ContainerListBlobHierarchySegmentResponse = {
statusCode: 200,
contentType: "application/xml",
requestId: context.contextId,
version: BLOB_API_VERSION,
date: context.startTime,
serviceEndpoint,
containerName,
prefix: options.prefix,
marker: options.marker,
maxResults: options.maxresults,
delimiter,
segment: {
blobPrefixes,
blobItems: blobItems.map(item => {
item.deleted = item.deleted !== true ? undefined : true;
return {
...item,
snapshot: item.snapshot || undefined,
blobTags: includeTags ? item.blobTags : undefined,
metadata: includeMetadata ? item.metadata : undefined,
properties: {
...item.properties,
etag: removeQuotationFromListBlobEtag(item.properties.etag),
tagCount: getBlobTagsCount(item.blobTags),
accessTierInferred:
item.properties.accessTierInferred === true ? true : undefined
}
};
})
},
clientRequestId: options.requestId,
nextMarker: `${nextMarker || ""}`
};
return response;
}