public class ShareDirectoryAsyncClient extends Object
Instantiating an Asynchronous Directory Client
ShareDirectoryAsyncClient client = new ShareFileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildDirectoryAsyncClient();
View this for additional ways to construct the client.
| Modifier and Type | Method and Description |
|---|---|
Mono<ShareDirectoryInfo> |
create()
Creates this directory in the file share and returns a response of
ShareDirectoryInfo to interact
with it. |
Mono<ShareFileAsyncClient> |
createFile(String fileName,
long maxSize)
Creates a file in this directory with specific name, max number of results and returns a response of
ShareDirectoryInfo to interact with it.
|
Mono<com.azure.core.http.rest.Response<ShareFileAsyncClient>> |
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 ShareDirectoryInfo to
interact with it.
|
Mono<com.azure.core.http.rest.Response<ShareFileAsyncClient>> |
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 ShareDirectoryInfo to
interact with it.
|
Mono<ShareDirectoryAsyncClient> |
createSubdirectory(String subdirectoryName)
Creates a subdirectory under current directory with specific name and returns a response of
ShareDirectoryAsyncClient to interact with it.
|
Mono<com.azure.core.http.rest.Response<ShareDirectoryAsyncClient>> |
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
ShareDirectoryAsyncClient to interact with it.
|
Mono<com.azure.core.http.rest.Response<ShareDirectoryInfo>> |
createWithResponse(FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata)
Creates a directory in the file share and returns a response of ShareDirectoryInfo to interact with it.
|
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<com.azure.core.http.rest.Response<Void>> |
deleteFileWithResponse(String fileName)
Deletes the file with specific name in this directory.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteFileWithResponse(String fileName,
ShareRequestConditions requestConditions)
Deletes the file with specific name in this directory.
|
Mono<Void> |
deleteSubdirectory(String subdirectoryName)
Deletes the subdirectory with specific name in this directory.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteSubdirectoryWithResponse(String subdirectoryName)
Deletes the subdirectory with specific name in this directory.
|
Mono<com.azure.core.http.rest.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<com.azure.core.http.rest.Response<Boolean>> |
existsWithResponse()
Determines if the directory this client represents exists in the cloud.
|
Mono<CloseHandlesInfo> |
forceCloseAllHandles(boolean recursive)
Closes all handles opened on the directory at the service.
|
Mono<CloseHandlesInfo> |
forceCloseHandle(String handleId)
Closes a handle on the directory.
|
Mono<com.azure.core.http.rest.Response<CloseHandlesInfo>> |
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,
com.azure.core.util.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.
|
ShareFileAsyncClient |
getFileClient(String fileName)
Constructs a ShareFileAsyncClient that interacts with the specified file.
|
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<ShareDirectoryProperties> |
getProperties()
Retrieves the properties of this directory.
|
Mono<com.azure.core.http.rest.Response<ShareDirectoryProperties>> |
getPropertiesWithResponse()
Retrieves the properties of this directory.
|
ShareServiceVersion |
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. |
ShareDirectoryAsyncClient |
getSubdirectoryClient(String subdirectoryName)
Constructs a ShareDirectoryAsyncClient that interacts with the specified directory.
|
com.azure.core.http.rest.PagedFlux<ShareFileItem> |
listFilesAndDirectories()
Lists all sub-directories and files in this directory without their prefix or maxResults in single page.
|
com.azure.core.http.rest.PagedFlux<ShareFileItem> |
listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options)
Lists all sub-directories and files in this directory with their prefix or snapshots.
|
com.azure.core.http.rest.PagedFlux<ShareFileItem> |
listFilesAndDirectories(String prefix,
Integer maxResultsPerPage)
Lists all sub-directories and files in this directory with their prefix or snapshots.
|
com.azure.core.http.rest.PagedFlux<HandleItem> |
listHandles(Integer maxResultPerPage,
boolean recursive)
List of open handles on a directory or a file.
|
Mono<ShareDirectorySetMetadataInfo> |
setMetadata(Map<String,String> metadata)
Sets the user-defined metadata to associate to the directory.
|
Mono<com.azure.core.http.rest.Response<ShareDirectorySetMetadataInfo>> |
setMetadataWithResponse(Map<String,String> metadata)
Sets the user-defined metadata to associate to the directory.
|
Mono<ShareDirectoryInfo> |
setProperties(FileSmbProperties smbProperties,
String filePermission)
Sets the properties of this directory.
|
Mono<com.azure.core.http.rest.Response<ShareDirectoryInfo>> |
setPropertiesWithResponse(FileSmbProperties smbProperties,
String filePermission)
Sets the properties of this directory.
|
public String getDirectoryUrl()
public ShareServiceVersion getServiceVersion()
public ShareFileAsyncClient getFileClient(String fileName)
If the file doesn't exist in this directory ShareFileAsyncClient.create(long) create} in the client
will need to be called before interaction with the file can happen.
fileName - Name of the filepublic ShareDirectoryAsyncClient getSubdirectoryClient(String subdirectoryName)
If the file doesn't exist in this directory ShareDirectoryAsyncClient.create() create} in the client
will need to be called before interaction with the directory can happen.
subdirectoryName - Name of the directorypublic Mono<Boolean> exists()
Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
public Mono<com.azure.core.http.rest.Response<Boolean>> existsWithResponse()
Code Samples
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
public Mono<ShareDirectoryInfo> create()
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.
directory info.ShareStorageException - If the directory has already existed, the parent directory does not exist or
directory name is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareDirectoryInfo>> createWithResponse(FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
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.
smbProperties - The SMB properties of the directory.filePermission - The file permission of the directory.metadata - Optional metadata to associate with the directoryShareStorageException - If the directory has already existed, the parent directory does not exist or
directory name is an invalid resource name.public Mono<Void> delete()
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.
ShareStorageException - If the share doesn't existpublic Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse()
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.
ShareStorageException - If the share doesn't existpublic Mono<ShareDirectoryProperties> getProperties()
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.
public Mono<com.azure.core.http.rest.Response<ShareDirectoryProperties>> getPropertiesWithResponse()
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.
public Mono<ShareDirectoryInfo> setProperties(FileSmbProperties smbProperties, String filePermission)
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.
smbProperties - The SMB properties of the directory.filePermission - The file permission of the directory.public Mono<com.azure.core.http.rest.Response<ShareDirectoryInfo>> setPropertiesWithResponse(FileSmbProperties smbProperties, String filePermission)
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.
smbProperties - The SMB properties of the directory.filePermission - The file permission of the directory.public Mono<ShareDirectorySetMetadataInfo> setMetadata(Map<String,String> metadata)
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.
metadata - Optional metadata to set on the directory, if null is passed the metadata for the directory is
clearedShareStorageException - If the directory doesn't exist or the metadata contains invalid keyspublic Mono<com.azure.core.http.rest.Response<ShareDirectorySetMetadataInfo>> setMetadataWithResponse(Map<String,String> metadata)
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.
metadata - Optional metadata to set on the directory, if null is passed the metadata for the directory is
clearedShareStorageException - If the directory doesn't exist or the metadata contains invalid keyspublic com.azure.core.http.rest.PagedFlux<ShareFileItem> listFilesAndDirectories()
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.
File info in the storage directorypublic com.azure.core.http.rest.PagedFlux<ShareFileItem> listFilesAndDirectories(String prefix, Integer maxResultsPerPage)
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.
prefix - Optional prefix which filters the results to return only files and directories whose name begins
with.maxResultsPerPage - Optional maximum number of files and/or directories to return per page. If the request
does not specify maxResultsPerPage or specifies a value greater than 5,000,
the server will return up to 5,000 items.File info in this directory with prefix and max number of return results.public com.azure.core.http.rest.PagedFlux<ShareFileItem> listFilesAndDirectories(ShareListFilesAndDirectoriesOptions options)
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.
options - Optional parameters.
the server will return up to 5,000 items.File info in this directory with prefix and max number of return results.public com.azure.core.http.rest.PagedFlux<HandleItem> listHandles(Integer maxResultPerPage, boolean recursive)
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.
maxResultPerPage - Optional maximum number of results will return per pagerecursive - Specifies operation should apply to the directory specified in the URI, its files, its
subdirectories and their files.handles in the directory that satisfy the requirementspublic Mono<CloseHandlesInfo> forceCloseHandle(String handleId)
ShareDirectoryAsyncClient.listHandles(Integer, boolean).
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.
handleId - Handle ID to be closed.public Mono<com.azure.core.http.rest.Response<CloseHandlesInfo>> forceCloseHandleWithResponse(String handleId)
ShareDirectoryAsyncClient.listHandles(Integer, boolean).
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.
handleId - Handle ID to be closed.public Mono<CloseHandlesInfo> forceCloseAllHandles(boolean recursive)
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.
recursive - Flag indicating if the operation should apply to all subdirectories and files contained in the
directory.public Mono<ShareDirectoryAsyncClient> createSubdirectory(String subdirectoryName)
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.
subdirectoryName - Name of the subdirectoryShareStorageException - If the subdirectory has already existed, the parent directory does not exist or
directory is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareDirectoryAsyncClient>> createSubdirectoryWithResponse(String subdirectoryName, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
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.
subdirectoryName - Name of the subdirectorysmbProperties - The SMB properties of the directory.filePermission - The file permission of the directory.metadata - Optional metadata to associate with the subdirectoryShareStorageException - If the directory has already existed, the parent directory does not exist or
subdirectory is an invalid resource name.public Mono<Void> deleteSubdirectory(String subdirectoryName)
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.
subdirectoryName - Name of the subdirectoryShareStorageException - If the subdirectory doesn't exist, the parent directory does not exist or
subdirectory name is an invalid resource name.public Mono<com.azure.core.http.rest.Response<Void>> deleteSubdirectoryWithResponse(String subdirectoryName)
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.
subdirectoryName - Name of the subdirectoryShareStorageException - If the subdirectory doesn't exist, the parent directory does not exist or
subdirectory name is an invalid resource name.public Mono<ShareFileAsyncClient> createFile(String fileName, long maxSize)
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.
fileName - Name of the filemaxSize - Size of the fileShareStorageException - If the file has already existed, the parent directory does not exist or file name
is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareFileAsyncClient>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
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.
fileName - Name of the filemaxSize - Max size of the filehttpHeaders - The user settable file http headers.smbProperties - The user settable file smb properties.filePermission - The file permission of the file.metadata - Optional name-value pairs associated with the file as metadata.ShareStorageException - If the directory has already existed, the parent directory does not exist or file
name is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareFileAsyncClient>> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions)
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.
fileName - Name of the filemaxSize - Max size of the filehttpHeaders - The user settable file http headers.smbProperties - The user settable file smb properties.filePermission - The file permission of the file.metadata - Optional name-value pairs associated with the file as metadata.requestConditions - ShareRequestConditionsShareStorageException - If the directory has already existed, the parent directory does not exist or file
name is an invalid resource name.public Mono<Void> deleteFile(String fileName)
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.
fileName - Name of the fileShareStorageException - If the directory doesn't exist or the file doesn't exist or file name is an invalid
resource name.public Mono<com.azure.core.http.rest.Response<Void>> deleteFileWithResponse(String fileName)
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.
fileName - Name of the fileShareStorageException - If the directory doesn't exist or the file doesn't exist or file name is an invalid
resource name.public Mono<com.azure.core.http.rest.Response<Void>> deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions)
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.
fileName - Name of the filerequestConditions - ShareRequestConditionsShareStorageException - If the directory doesn't exist or the file doesn't exist or file name is an invalid
resource name.public String getShareSnapshotId()
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());
DateTime value that identifies the share snapshot to its base
share.public String getShareName()
Get the share name.
String shareName = shareDirectoryAsyncClient.getShareName();
System.out.println("The share name of the directory is " + shareName);
public String getDirectoryPath()
Get directory path.
String directoryPath = shareDirectoryAsyncClient.getDirectoryPath();
System.out.println("The name of the directory is " + directoryPath);
public String getAccountName()
public com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline powering this client.public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)
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
shareServiceSasSignatureValues - ShareServiceSasSignatureValuesString representing the SAS query parameters.public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, com.azure.core.util.Context context)
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"));
shareServiceSasSignatureValues - ShareServiceSasSignatureValuescontext - Additional context that is passed through the code when generating a SAS.String representing the SAS query parameters.Visit the Azure for Java Developers site for more Java documentation, including quick starts, tutorials, and code samples.