Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for file key #18099

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob-nio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Release History

## 12.0.0-beta.3 (Unreleased)

- Added support for file key on AzureBasicFileAttributes and AzureBlobFileAttributes

## 12.0.0-beta.2 (2020-08-13)
- Added checks to ensure file system has not been closed before operating on data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class AzureBasicFileAttributes implements BasicFileAttributes {
}

private final BlobProperties properties;
private final AzureResource resource;

/*
There are some work-arounds we could do to try to accommodate virtual directories such as making a checkDirStatus
Expand All @@ -54,7 +55,8 @@ public final class AzureBasicFileAttributes implements BasicFileAttributes {
*/
AzureBasicFileAttributes(Path path) throws IOException {
try {
this.properties = new AzureResource(path).getBlobClient().getProperties();
this.resource = new AzureResource(path);
this.properties = resource.getBlobClient().getProperties();
} catch (BlobStorageException e) {
throw LoggingUtility.logError(logger, new IOException(e));
}
Expand Down Expand Up @@ -148,12 +150,12 @@ public long size() {
}

/**
* Unsupported.
* Returns the url of the resource.
*
* @throws UnsupportedOperationException Operation not supported.
* @return The file key, which is the url.
*/
@Override
public Object fileKey() {
throw new UnsupportedOperationException();
return this.resource.getBlobClient().getBlobUrl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public final class AzureBlobFileAttributes implements BasicFileAttributes {
private final ClientLogger logger = new ClientLogger(AzureBlobFileAttributes.class);

private final BlobProperties properties;
private final AzureResource resource;

AzureBlobFileAttributes(Path path) throws IOException {
try {
this.properties = new AzureResource(path).getBlobClient().getProperties();
this.resource = new AzureResource(path);
this.properties = resource.getBlobClient().getProperties();
} catch (BlobStorageException e) {
throw LoggingUtility.logError(logger, new IOException("Path: " + path.toString(), e));
}
Expand Down Expand Up @@ -321,11 +323,12 @@ public long size() {
}

/**
* Unsupported.
* @throws UnsupportedOperationException Operation not supported.
* Returns the url of the resource.
*
* @return The file key, which is the url.
*/
@Override
public Object fileKey() {
throw new UnsupportedOperationException();
return resource.getBlobClient().getBlobUrl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AttributeViewTest extends APISpec {
FileTime.from(props.getLastModified().toInstant()) == attr.lastModifiedTime()
FileTime.from(props.getCreationTime().toInstant()) == attr.creationTime()
attr.isRegularFile()
bc.getBlobUrl() == attr.fileKey()
!attr.isDirectory()
!attr.isSymbolicLink()
!attr.isOther()
Expand Down Expand Up @@ -86,6 +87,7 @@ class AttributeViewTest extends APISpec {
FileTime.from(props.getLastModified().toInstant()) == attr.lastModifiedTime()
FileTime.from(props.getCreationTime().toInstant()) == attr.creationTime()
attr.isRegularFile()
bc.getBlobUrl() == attr.fileKey()
!attr.isDirectory()
!attr.isSymbolicLink()
!attr.isOther()
Expand Down
Loading