Skip to content

Commit

Permalink
[storage-blob] allow empty blobName to support root directory in data…
Browse files Browse the repository at this point in the history
…lake (Azure#12890)

* allow empty blobName to support root directory in datalake

* remove .only

* Merge branch 'master' into storage/issues/12813

* changelog
  • Loading branch information
ljian3377 authored Jan 6, 2021
1 parent 736de08 commit cd97a78
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 3 deletions.
4 changes: 1 addition & 3 deletions sdk/storage/storage-blob/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2451,9 +2451,7 @@ export class BlobClient extends StorageClient {
// doing the same in the SDK side so that the user doesn't have to replace "\" instances in the blobName
blobName = blobName.replace(/\\/g, "/");

if (!blobName) {
throw new Error("Provided blobName is invalid.");
} else if (!containerName) {
if (!containerName) {
throw new Error("Provided containerName is invalid.");
}

Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 12.3.0-beta.2 (Unreleased)

- Now you can get the functionality of the root directory via the `DataLakeDirectoryClient` created via `FileSystemClient.getDirectoryClient("")`. Fixed bug [12813](https://github.com/Azure/azure-sdk-for-js/issues/12813).

## 12.3.0-beta.1 (2020-12-09)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions sdk/storage/storage-file-datalake/test/node/sas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,28 @@ describe("SAS generation Node.js only for directory SAS", () => {
await directoryClientwithSAS.setPermissions(permissions);
});

it("generateDataLakeSASQueryParameters for root directory should work", async () => {
const rootDirName = "";
const rootDirectoryClient = fileSystemClient.getDirectoryClient(rootDirName);

const directorySAS = generateDataLakeSASQueryParameters(
{
fileSystemName: fileSystemClient.name,
pathName: rootDirectoryClient.name,
isDirectory: true,
directoryDepth: 1,
expiresOn: tmr,
permissions: DirectorySASPermissions.parse("racwdlmeop"),
version: "2020-02-10"
},
sharedKeyCredential as StorageSharedKeyCredential
);
const sasURL = `${rootDirectoryClient.url}?${directorySAS}`;
const directoryClientwithSAS = new DataLakeDirectoryClient(sasURL);

await directoryClientwithSAS.getAccessControl();
});

function getDefualtDirctorySAS(directoryName: string): SASQueryParameters {
return generateDataLakeSASQueryParameters(
{
Expand Down

0 comments on commit cd97a78

Please sign in to comment.