ShareDirectoryAsyncClient Class
- java.
lang. Object - com.
azure. storage. file. share. ShareDirectoryAsyncClient
- com.
public class ShareDirectoryAsyncClient
This class provides a client that contains all the operations for interacting with directory in Azure Storage File Service. Operations allowed by the client are creating, deleting and listing subdirectory and file, retrieving properties, setting metadata and list or force close handles of the directory or file.
Instantiating an Asynchronous Directory Client
ShareDirectoryAsyncClient client = new ShareFileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildDirectoryAsyncClient();
View ShareFileClientBuilder for additional ways to construct the client.
Method Summary
Modifier and Type | Method and Description |
---|---|
Mono<Share |
create()
Creates this directory in the file share and returns a response of ShareDirectoryInfo to interact with it. |
Mono<Share |
createFile(String fileName, long maxSize)
Creates a file in this directory with specific name, max number of results and returns a response of Share |
Mono<Response<Share |
createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
Creates a file in this directory with specific name and returns a response of Share |
Mono<Response<Share |
createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions)
Creates a file in this directory with specific name and returns a response of Share |
Mono<Share |
createIfNotExists()
Creates this directory in the file share if it does not exist. |
Mono<Response<Share |
createIfNotExistsWithResponse(ShareDirectoryCreateOptions options)
Creates a directory in the file share if it does not exist. |
Mono<Share |
createSubdirectory(String subdirectoryName)
Creates a subdirectory under current directory with specific name and returns a response of Share |
Mono<Share |
createSubdirectoryIfNotExists(String subdirectoryName)
Creates a subdirectory under current directory with specific name if it does not exist and returns a response of Share |
Mono<Response<Share |
createSubdirectoryIfNotExistsWithResponse(String subdirectoryName, ShareDirectoryCreateOptions options)
Creates a subdirectory under current directory with specific name and metadata if it does not exist, and returns a response of Share |
Mono<Response<Share |
createSubdirectoryWithResponse(String subdirectoryName, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
Creates a subdirectory under current directory with specific name , metadata and returns a response of Share |
Mono<Response<Share |
createWithResponse(FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
Creates a directory in the file share and returns a response of Share |
Mono<Void> |
delete()
Deletes the directory in the file share. |
Mono<Void> |
deleteFile(String fileName)
Deletes the file with specific name in this directory. |
Mono<Boolean> |
deleteFileIfExists(String fileName)
Deletes the file with specific name in this directory if it exists. |
Mono<Response<Boolean>> |
deleteFileIfExistsWithResponse(String fileName)
Deletes the file with specific name in this directory if it exists. |
Mono<Response<Boolean>> |
deleteFileIfExistsWithResponse(String fileName, ShareRequestConditions requestConditions)
Deletes the file with specific name in this directory if it exists. |
Mono<Response<Void>> |
deleteFileWithResponse(String fileName)
Deletes the file with specific name in this directory. |
Mono<Response<Void>> |
deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions)
Deletes the file with specific name in this directory. |
Mono<Boolean> |
deleteIfExists()
Deletes the directory in the file share if it exists. |
Mono<Response<Boolean>> |
deleteIfExistsWithResponse()
Deletes the directory in the file share if it exists. |
Mono<Void> |
deleteSubdirectory(String subdirectoryName)
Deletes the subdirectory with specific name in this directory. |
Mono<Boolean> |
deleteSubdirectoryIfExists(String subdirectoryName)
Deletes the subdirectory with specific name in this directory if it exists. |
Mono<Response<Boolean>> |
deleteSubdirectoryIfExistsWithResponse(String subdirectoryName)
Deletes the subdirectory with specific name in this directory if it exists. |
Mono<Response<Void>> |
deleteSubdirectoryWithResponse(String subdirectoryName)
Deletes the subdirectory with specific name in this directory. |
Mono<Response<Void>> |
deleteWithResponse()
Deletes the directory in the file share. |
Mono<Boolean> |
exists()
Determines if the directory this client represents exists in the cloud. |
Mono<Response<Boolean>> |
existsWithResponse()
Determines if the directory this client represents exists in the cloud. |
Mono<Close |
forceCloseAllHandles(boolean recursive)
Closes all handles opened on the directory at the service. |
Mono<Close |
forceCloseHandle(String handleId)
Closes a handle on the directory. |
Mono<Response<Close |
forceCloseHandleWithResponse(String handleId)
Closes a handle on the directory. |
String |
generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)
Generates a service SAS for the directory using the specified ShareServiceSasSignatureValues |
String |
generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)
Generates a service SAS for the directory using the specified ShareServiceSasSignatureValues |
String |
getAccountName()
Get associated account name. |
String |
getDirectoryPath()
Get directory path of the client. |
String |
getDirectoryUrl()
Get the url of the storage directory client. |
Share |
getFileClient(String fileName)
Constructs a Share |
Http |
getHttpPipeline()
Gets the HttpPipeline powering this client. |
Mono<Share |
getProperties()
Retrieves the properties of this directory. |
Mono<Response<Share |
getPropertiesWithResponse()
Retrieves the properties of this directory. |
Share |
getServiceVersion()
Gets the service version the client is using. |
String |
getShareName()
Get the share name of directory client. |
String |
getShareSnapshotId()
Get snapshot id which attached to ShareDirectoryAsyncClient. |
Share |
getSubdirectoryClient(String subdirectoryName)
Constructs a Share |
Paged |
listFilesAndDirectories()
Lists all sub-directories and files in this directory without their prefix or max |
Paged |
listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options)
Lists all sub-directories and files in this directory with their prefix or snapshots. |
Paged |
listFilesAndDirectories(String prefix, Integer maxResultsPerPage)
Lists all sub-directories and files in this directory with their prefix or snapshots. |
Paged |
listHandles(Integer maxResultPerPage, boolean recursive)
List of open handles on a directory or a file. |
Mono<Share |
rename(String destinationPath)
Moves the directory to another location within the share. |
Mono<Response<Share |
renameWithResponse(ShareFileRenameOptions options)
Moves the directory to another location within the share. |
Mono<Share |
setMetadata(Map<String,String> metadata)
Sets the user-defined metadata to associate to the directory. |
Mono<Response<Share |
setMetadataWithResponse(Map<String,String> metadata)
Sets the user-defined metadata to associate to the directory. |
Mono<Share |
setProperties(FileSmbProperties smbProperties, String filePermission)
Sets the properties of this directory. |
Mono<Response<Share |
setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission)
Sets the properties of this directory. |
Methods inherited from java.lang.Object
Method Details
create
public Mono
Creates this directory in the file share and returns a response of ShareDirectoryInfo to interact with it.
Code Samples
Create the directory
shareDirectoryAsyncClient.create().subscribe(
response -> {
},
error -> System.err.print(error.toString()),
() -> System.out.println("Completed creating the directory!")
);
For more information, see the Azure Docs.
Returns:
createFile
public Mono
Creates a file in this directory with specific name, max number of results and returns a response of ShareDirectoryInfo to interact with it.
Code Samples
Create 1k file with named "myFile"
shareDirectoryAsyncClient.createFile("myfile", 1024).subscribe(
response -> {
},
error -> System.err.println(error.toString()),
() -> System.out.println("Completed creating the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
createFileWithResponse
public Mono<>
Creates a file in this directory with specific name and returns a response of ShareDirectoryInfo to interact with it.
Code Samples
Create the file named "myFile"
ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
.setContentType("text/html")
.setContentEncoding("gzip")
.setContentLanguage("en")
.setCacheControl("no-transform")
.setContentDisposition("attachment");
FileSmbProperties smbProperties = new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey");
String filePermission = "filePermission";
// NOTE: filePermission and filePermissionKey should never be both set
shareDirectoryAsyncClient.createFileWithResponse("myFile", 1024, httpHeaders, smbProperties, filePermission,
Collections.singletonMap("directory", "metadata")).subscribe(
response -> System.out.printf("Creating the file completed with status code %d", response.getStatusCode()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed creating the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
createFileWithResponse
public Mono<>
Creates a file in this directory with specific name and returns a response of ShareDirectoryInfo to interact with it.
Code Samples
Create the file named "myFile"
ShareFileHttpHeaders httpHeaders = new ShareFileHttpHeaders()
.setContentType("text/html")
.setContentEncoding("gzip")
.setContentLanguage("en")
.setCacheControl("no-transform")
.setContentDisposition("attachment");
FileSmbProperties smbProperties = new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey");
String filePermission = "filePermission";
// NOTE: filePermission and filePermissionKey should never be both set
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
shareDirectoryAsyncClient.createFileWithResponse("myFile", 1024, httpHeaders, smbProperties, filePermission,
Collections.singletonMap("directory", "metadata"), requestConditions).subscribe(
response -> System.out.printf("Creating the file completed with status code %d", response.getStatusCode()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed creating the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
createIfNotExists
public Mono
Creates this directory in the file share if it does not exist.
Code Samples
Create the directory
shareDirectoryAsyncClient.createIfNotExists().subscribe(response ->
System.out.printf("Created at %s%n", response.getLastModified()));
For more information, see the Azure Docs.
Returns:
createIfNotExistsWithResponse
public Mono<>
Creates a directory in the file share if it does not exist.
Code Samples
Create the directory
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
ShareDirectoryCreateOptions options = new ShareDirectoryCreateOptions().setSmbProperties(smbProperties)
.setFilePermission(filePermission).setMetadata(metadata);
shareDirectoryAsyncClient.createIfNotExistsWithResponse(options).subscribe(response -> {
if (response.getStatusCode() == 409) {
System.out.println("Already exists.");
} else {
System.out.println("successfully created.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
createSubdirectory
public Mono
Creates a subdirectory under current directory with specific name and returns a response of ShareDirectoryAsyncClient to interact with it.
Code Samples
Create the sub directory "subdir"
shareDirectoryAsyncClient.createSubdirectory("subdir")
.doOnSuccess(response -> System.out.println("Completed creating the subdirectory."));
For more information, see the Azure Docs.
Parameters:
Returns:
createSubdirectoryIfNotExists
public Mono
Creates a subdirectory under current directory with specific name if it does not exist and returns a response of ShareDirectoryAsyncClient to interact with it.
Code Samples
Create the sub directory "subdir"
shareDirectoryAsyncClient.createSubdirectoryIfNotExists("subdir")
.switchIfEmpty(Mono.<ShareDirectoryAsyncClient>empty()
.doOnSuccess(x -> System.out.println("Already exists.")))
.subscribe(response -> System.out.println("Create completed."));
For more information, see the Azure Docs.
Parameters:
Returns:
createSubdirectoryIfNotExistsWithResponse
public Mono<>
Creates a subdirectory under current directory with specific name and metadata if it does not exist, and returns a response of ShareDirectoryAsyncClient to interact with it.
Code Samples
Create the subdirectory named "subdir", with metadata
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
ShareDirectoryCreateOptions options = new ShareDirectoryCreateOptions().setSmbProperties(smbProperties)
.setFilePermission(filePermission).setMetadata(metadata);
shareDirectoryAsyncClient.createSubdirectoryIfNotExistsWithResponse("subdir", options).subscribe(response -> {
if (response.getStatusCode() == 409) {
System.out.println("Already exists.");
} else {
System.out.println("successfully created.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
Mono
indicates the specified
subdirectory already existed at this location.createSubdirectoryWithResponse
public Mono<>
Creates a subdirectory under current directory with specific name , metadata and returns a response of ShareDirectoryAsyncClient to interact with it.
Code Samples
Create the subdirectory named "subdir", with metadata
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
shareDirectoryAsyncClient.createSubdirectoryWithResponse("subdir", smbProperties, filePermission, metadata).subscribe(
response ->
System.out.println("Successfully creating the subdirectory with status code: "
+ response.getStatusCode()),
error -> System.err.println(error.toString())
);
For more information, see the Azure Docs.
Parameters:
Returns:
createWithResponse
public Mono<>
Creates a directory in the file share and returns a response of ShareDirectoryInfo to interact with it.
Code Samples
Create the directory
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Map<String, String> metadata = Collections.singletonMap("directory", "metadata");
shareDirectoryAsyncClient.createWithResponse(smbProperties, filePermission, metadata).subscribe(
response ->
System.out.println("Completed creating the directory with status code:" + response.getStatusCode()),
error -> System.err.print(error.toString())
);
For more information, see the Azure Docs.
Parameters:
Returns:
delete
public Mono
Deletes the directory in the file share.
Code Samples
Delete the directory
shareDirectoryAsyncClient.delete().subscribe(
response -> {
},
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the file.")
);
For more information, see the Azure Docs.
Returns:
deleteFile
public Mono
Deletes the file with specific name in this directory.
Code Samples
Delete the file "filetest"
shareDirectoryAsyncClient.deleteFile("myfile").subscribe(
response -> {
},
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
deleteFileIfExists
public Mono
Deletes the file with specific name in this directory if it exists.
Code Samples
Delete the file "filetest"
shareDirectoryAsyncClient.deleteFileIfExists("myfile").subscribe(deleted -> {
if (deleted) {
System.out.println("Successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
true
indicates that the file was successfully
deleted, false
indicates that the file did not exist.deleteFileIfExistsWithResponse
public Mono<>
Deletes the file with specific name in this directory if it exists.
Code Samples
Delete the file "filetest"
shareDirectoryAsyncClient.deleteFileIfExistsWithResponse("myfile").subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
deleteFileIfExistsWithResponse
public Mono<>
Deletes the file with specific name in this directory if it exists.
Code Samples
Delete the file "filetest"
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
shareDirectoryAsyncClient.deleteFileIfExistsWithResponse("myfile", requestConditions).subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
deleteFileWithResponse
public Mono<>
Deletes the file with specific name in this directory.
Code Samples
Delete the file "filetest"
shareDirectoryAsyncClient.deleteFileWithResponse("myfile").subscribe(
response -> System.out.printf("Delete file completed with status code %d", response.getStatusCode()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
deleteFileWithResponse
public Mono<>
Deletes the file with specific name in this directory.
Code Samples
Delete the file "filetest"
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
shareDirectoryAsyncClient.deleteFileWithResponse("myfile", requestConditions).subscribe(
response -> System.out.printf("Delete file completed with status code %d", response.getStatusCode()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the file.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
deleteIfExists
public Mono
Deletes the directory in the file share if it exists.
Code Samples
Delete the directory
shareDirectoryAsyncClient.deleteIfExists().subscribe(deleted -> {
if (deleted) {
System.out.println("Successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
For more information, see the Azure Docs.
Returns:
true
indicates that the directory was successfully
deleted, false
indicates that the directory did not exist.deleteIfExistsWithResponse
public Mono<>
Deletes the directory in the file share if it exists.
Code Samples
Delete the directory
shareDirectoryAsyncClient.deleteIfExistsWithResponse().subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
For more information, see the Azure Docs.
Returns:
deleteSubdirectory
public Mono
Deletes the subdirectory with specific name in this directory.
Code Samples
Delete the subdirectory named "subdir"
shareDirectoryAsyncClient.deleteSubdirectory("mysubdirectory").subscribe(
response -> {
},
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the subdirectory.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
deleteSubdirectoryIfExists
public Mono
Deletes the subdirectory with specific name in this directory if it exists.
Code Samples
Delete the subdirectory named "subdir"
shareDirectoryAsyncClient.deleteSubdirectoryIfExists("mysubdirectory").subscribe(deleted -> {
if (deleted) {
System.out.println("Successfully deleted.");
} else {
System.out.println("Does not exist.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
true
indicates that the subdirectory was successfully
deleted, false
indicates that the subdirectory did not exist.deleteSubdirectoryIfExistsWithResponse
public Mono<>
Deletes the subdirectory with specific name in this directory if it exists.
Code Samples
Delete the subdirectory named "subdir"
shareDirectoryAsyncClient.deleteSubdirectoryIfExistsWithResponse("mysubdirectory").subscribe(response -> {
if (response.getStatusCode() == 404) {
System.out.println("Does not exist.");
} else {
System.out.println("successfully deleted.");
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
deleteSubdirectoryWithResponse
public Mono<>
Deletes the subdirectory with specific name in this directory.
Code Samples
Delete the subdirectory named "subdir"
shareDirectoryAsyncClient.deleteSubdirectoryWithResponse("mysubdirectory").subscribe(
response -> System.out.printf("Delete subdirectory completed with status code %d",
response.getStatusCode()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed deleting the subdirectory.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
deleteWithResponse
public Mono<>
Deletes the directory in the file share.
Code Samples
Delete the directory
shareDirectoryAsyncClient.deleteWithResponse().subscribe(
response -> System.out.printf("Delete completed with status code %d", response.getStatusCode()),
error -> System.err.println(error.toString())
);
For more information, see the Azure Docs.
Returns:
exists
public Mono
Determines if the directory this client represents exists in the cloud.
Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
Returns:
existsWithResponse
public Mono<>
Determines if the directory this client represents exists in the cloud.
Code Samples
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
Returns:
forceCloseAllHandles
public Mono
Closes all handles opened on the directory at the service.
Code Samples
Force close all handles recursively.
shareDirectoryAsyncClient.forceCloseAllHandles(true).subscribe(closeHandlesInfo ->
System.out.printf("Closed %d open handles on the directory%nFailed to close %d open handles on the "
+ "directory%n", closeHandlesInfo.getClosedHandles(), closeHandlesInfo.getFailedHandles()));
For more information, see the Azure Docs.
Parameters:
Returns:
forceCloseHandle
public Mono
Closes a handle on the directory. This is intended to be used alongside listHandles(Integer maxResultPerPage, boolean recursive).
Code Samples
Force close handles returned by list handles.
shareDirectoryAsyncClient.listHandles(null, true).subscribe(handleItem ->
shareDirectoryAsyncClient.forceCloseHandle(handleItem.getHandleId()).subscribe(ignored ->
System.out.printf("Closed handle %s on resource %s%n",
handleItem.getHandleId(), handleItem.getPath())));
For more information, see the Azure Docs.
Parameters:
Returns:
forceCloseHandleWithResponse
public Mono<>
Closes a handle on the directory. This is intended to be used alongside listHandles(Integer maxResultPerPage, boolean recursive).
Code Samples
Force close handles returned by list handles.
shareDirectoryAsyncClient.listHandles(null, true).subscribe(handleItem ->
shareDirectoryAsyncClient.forceCloseHandleWithResponse(handleItem.getHandleId()).subscribe(response ->
System.out.printf("Closing handle %s on resource %s completed with status code %d%n",
handleItem.getHandleId(), handleItem.getPath(), response.getStatusCode())));
For more information, see the Azure Docs.
Parameters:
Returns:
generateSas
public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)
Generates a service SAS for the directory using the specified ShareServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential
See ShareServiceSasSignatureValues for more information on how to construct a service SAS.
Code Samples
OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
ShareFileSasPermission permission = new ShareFileSasPermission().setReadPermission(true);
ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission)
.setStartTime(OffsetDateTime.now());
shareDirectoryAsyncClient.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
Parameters:
Returns:
String
representing the SAS query parameters.generateSas
public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)
Generates a service SAS for the directory using the specified ShareServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential
See ShareServiceSasSignatureValues for more information on how to construct a service SAS.
Code Samples
OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
ShareFileSasPermission permission = new ShareFileSasPermission().setReadPermission(true);
ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission)
.setStartTime(OffsetDateTime.now());
// Client must be authenticated via StorageSharedKeyCredential
shareDirectoryAsyncClient.generateSas(values, new Context("key", "value"));
Parameters:
Returns:
String
representing the SAS query parameters.getAccountName
public String getAccountName()
Get associated account name.
Returns:
getDirectoryPath
public String getDirectoryPath()
Get directory path of the client.
Get directory path.
String directoryPath = shareDirectoryAsyncClient.getDirectoryPath();
System.out.println("The name of the directory is " + directoryPath);
Returns:
getDirectoryUrl
public String getDirectoryUrl()
Get the url of the storage directory client.
Returns:
getFileClient
public ShareFileAsyncClient getFileClient(String fileName)
Constructs a ShareFileAsyncClient that interacts with the specified file.
If the file doesn't exist in this directory create(long maxSize) create} in the client will need to be called before interaction with the file can happen.
Parameters:
Returns:
getHttpPipeline
public HttpPipeline getHttpPipeline()
Gets the HttpPipeline powering this client.
Returns:
getProperties
public Mono
Retrieves the properties of this directory. The properties include directory metadata, last modified date, is server encrypted, and eTag.
Code Samples
Retrieve directory properties
shareDirectoryAsyncClient.getProperties().subscribe(properties -> {
System.out.printf("Directory latest modified date is %s.", properties.getLastModified());
});
For more information, see the Azure Docs.
Returns:
getPropertiesWithResponse
public Mono<>
Retrieves the properties of this directory. The properties include directory metadata, last modified date, is server encrypted, and eTag.
Code Samples
Retrieve directory properties
shareDirectoryAsyncClient.getPropertiesWithResponse().subscribe(properties -> {
System.out.printf("Directory latest modified date is %s:", properties.getValue().getLastModified());
});
For more information, see the Azure Docs.
Returns:
getServiceVersion
public ShareServiceVersion getServiceVersion()
Gets the service version the client is using.
Returns:
getShareName
public String getShareName()
Get the share name of directory client.
Get the share name.
String shareName = shareDirectoryAsyncClient.getShareName();
System.out.println("The share name of the directory is " + shareName);
Returns:
getShareSnapshotId
public String getShareSnapshotId()
Get snapshot id which attached to ShareDirectoryAsyncClient. Return null
if no snapshot id attached.
Code Samples
Get the share snapshot id.
OffsetDateTime currentTime = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC);
ShareDirectoryAsyncClient shareDirectoryAsyncClient = new ShareFileClientBuilder()
.endpoint("https://${accountName}.file.core.windows.net")
.sasToken("${SASToken}")
.shareName("myshare")
.resourcePath("mydirectory")
.snapshot(currentTime.toString())
.buildDirectoryAsyncClient();
System.out.printf("Snapshot ID: %s%n", shareDirectoryAsyncClient.getShareSnapshotId());
Returns:
DateTime
value that identifies the share snapshot to its base
share.getSubdirectoryClient
public ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName)
Constructs a ShareDirectoryAsyncClient that interacts with the specified directory.
If the file doesn't exist in this directory create() create} in the client will need to be called before interaction with the directory can happen.
Parameters:
Returns:
listFilesAndDirectories
public PagedFlux
Lists all sub-directories and files in this directory without their prefix or maxResults in single page.
Code Samples
List all sub-directories and files in the account
shareDirectoryAsyncClient.listFilesAndDirectories().subscribe(
fileRef -> System.out.printf("Is the resource a directory? %b. The resource name is: %s.",
fileRef.isDirectory(), fileRef.getName()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed listing the directories and files.")
);
For more information, see the Azure Docs.
Returns:
listFilesAndDirectories
public PagedFlux
Lists all sub-directories and files in this directory with their prefix or snapshots.
Code Samples
List all sub-directories with "subdir" prefix and return 10 results in the account
shareDirectoryAsyncClient.listFilesAndDirectories(new ShareListFilesAndDirectoriesOptions()
.setPrefix("subdir").setMaxResultsPerPage(10))
.subscribe(fileRef -> System.out.printf("Is the resource a directory? %b. The resource name is: %s.",
fileRef.isDirectory(), fileRef.getName()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed listing the directories and files."));
For more information, see the Azure Docs.
Parameters:
Returns:
listFilesAndDirectories
public PagedFlux
Lists all sub-directories and files in this directory with their prefix or snapshots.
Code Samples
List all sub-directories with "subdir" prefix and return 10 results in the account
shareDirectoryAsyncClient.listFilesAndDirectories("subdir", 10).subscribe(
fileRef -> System.out.printf("Is the resource a directory? %b. The resource name is: %s.",
fileRef.isDirectory(), fileRef.getName()),
error -> System.err.println(error.toString()),
() -> System.out.println("Completed listing the directories and files.")
);
For more information, see the Azure Docs.
Parameters:
Returns:
listHandles
public PagedFlux
List of open handles on a directory or a file.
Code Samples
Get 10 handles with recursive call.
shareDirectoryAsyncClient.listHandles(10, true)
.subscribe(handleItem -> System.out.printf("Get handles completed with handle id %s",
handleItem.getHandleId()));
For more information, see the Azure Docs.
Parameters:
Returns:
rename
public Mono
Moves the directory to another location within the share. For more information see the Azure Docs.
Code Samples
ShareDirectoryAsyncClient renamedClient = client.rename(destinationPath).block();
System.out.println("Directory Client has been renamed");
Parameters:
Returns:
renameWithResponse
public Mono<>
Moves the directory to another location within the share. For more information see the Azure Docs.
Code Samples
FileSmbProperties smbProperties = new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey");
ShareFileRenameOptions options = new ShareFileRenameOptions(destinationPath)
.setDestinationRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))
.setSourceRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))
.setIgnoreReadOnly(false)
.setReplaceIfExists(false)
.setFilePermission("filePermission")
.setSmbProperties(smbProperties);
ShareDirectoryAsyncClient newRenamedClient = client.renameWithResponse(options).block().getValue();
System.out.println("Directory Client has been renamed");
Parameters:
Returns:
setMetadata
public Mono
Sets the user-defined metadata to associate to the directory.
If null
is passed for the metadata it will clear the metadata associated to the directory.
Code Samples
Set the metadata to "directory:updatedMetadata"
shareDirectoryAsyncClient.setMetadata(Collections.singletonMap("directory", "updatedMetadata"))
.subscribe(response -> System.out.println("Setting the directory metadata completed."));
Clear the metadata of the directory
shareDirectoryAsyncClient.setMetadata(null)
.doOnSuccess(response -> System.out.println("Clearing the directory metadata completed"));
For more information, see the Azure Docs.
Parameters:
Returns:
setMetadataWithResponse
public Mono<>
Sets the user-defined metadata to associate to the directory.
If null
is passed for the metadata it will clear the metadata associated to the directory.
Code Samples
Set the metadata to "directory:updatedMetadata"
shareDirectoryAsyncClient.setMetadataWithResponse(Collections.singletonMap("directory", "updatedMetadata"))
.subscribe(response -> System.out.println("Setting the directory metadata completed with status code:"
+ response.getStatusCode()));
Clear the metadata of the directory
shareDirectoryAsyncClient.setMetadataWithResponse(null).subscribe(
response -> System.out.printf("Clearing the directory metadata completed with status code %d",
response.getStatusCode()));
For more information, see the Azure Docs.
Parameters:
Returns:
setProperties
public Mono
Sets the properties of this directory. The properties include the file SMB properties and the file permission.
Code Samples
Set directory properties
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
shareDirectoryAsyncClient.setProperties(smbProperties, filePermission).subscribe(properties -> {
System.out.printf("Directory latest modified date is %s:", properties.getLastModified());
});
For more information, see the Azure Docs.
Parameters:
Returns:
setPropertiesWithResponse
public Mono<>
Sets the properties of this directory. The properties include the file SMB properties and the file permission.
Code Samples
Set directory properties
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
shareDirectoryAsyncClient.setPropertiesWithResponse(smbProperties, filePermission).subscribe(properties -> {
System.out.printf("Directory latest modified date is %s:", properties.getValue().getLastModified());
});
For more information, see the Azure Docs.
Parameters:
Returns:
Applies to
Azure SDK for Java
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin