Class ShareFileAsyncClient
Instantiating an Asynchronous File Client
ShareFileAsyncClient client = new ShareFileClientBuilder() .connectionString("${connectionString}") .endpoint("${endpoint}") .buildFileAsyncClient();
View this
for additional ways to construct the client.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.abortCopyWithResponse
(String copyId) Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.abortCopyWithResponse
(String copyId, ShareRequestConditions requestConditions) Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.com.azure.core.util.polling.PollerFlux
<ShareFileCopyInfo, Void> beginCopy
(String sourceUrl, FileSmbProperties smbProperties, String filePermission, PermissionCopyModeType filePermissionCopyMode, Boolean ignoreReadOnly, Boolean setArchiveAttribute, Map<String, String> metadata, Duration pollInterval, ShareRequestConditions destinationRequestConditions) Copies a blob or file to a destination file within the storage account.com.azure.core.util.polling.PollerFlux
<ShareFileCopyInfo, Void> beginCopy
(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval) Copies a blob or file to a destination file within the storage account.com.azure.core.util.polling.PollerFlux
<ShareFileCopyInfo, Void> Copies a blob or file to a destination file within the storage account.clearRange
(long length) Clear a range of bytes to specific of a file in storage file service.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> clearRangeWithResponse
(long length, long offset) Clear a range of bytes to specific of a file in storage file service.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> clearRangeWithResponse
(long length, long offset, ShareRequestConditions requestConditions) Clear a range of bytes to specific of a file in storage file service.create
(long maxSize) Creates a file in the storage account and returns a response ofShareFileInfo
to interact with it.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> createWithResponse
(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String, String> metadata) Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> createWithResponse
(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String, String> metadata, ShareRequestConditions requestConditions) Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> createWithResponse
(ShareFileCreateOptions options) Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.delete()
Deletes the file associate with the client.Deletes the file associate with the client if it exists.deleteIfExistsWithResponse
(ShareRequestConditions requestConditions) Deletes the file associate with the client if it does not exist.Deletes the file associate with the client.deleteWithResponse
(ShareRequestConditions requestConditions) Deletes the file associate with the client.download()
Downloads a file from the system, including its metadata and propertiesdownloadToFile
(String downloadFilePath) Downloads a file from the system, including its metadata and properties into a file specified by the path.Mono
<com.azure.core.http.rest.Response<ShareFileProperties>> downloadToFileWithResponse
(String downloadFilePath, ShareFileRange range) Downloads a file from the system, including its metadata and properties into a file specified by the path.Mono
<com.azure.core.http.rest.Response<ShareFileProperties>> downloadToFileWithResponse
(String downloadFilePath, ShareFileRange range, ShareRequestConditions requestConditions) Downloads a file from the system, including its metadata and properties into a file specified by the path.downloadWithResponse
(ShareFileRange range, Boolean rangeGetContentMD5) Downloads a file from the system, including its metadata and propertiesdownloadWithResponse
(ShareFileRange range, Boolean rangeGetContentMD5, ShareRequestConditions requestConditions) Downloads a file from the system, including its metadata and propertiesDownloads a file from the system, including its metadata and propertiesexists()
Determines if the file this client represents exists in the cloud.Determines if the file this client represents exists in the cloud.Closes all handles opened on the file at the service.forceCloseHandle
(String handleId) Closes a handle on the file.Mono
<com.azure.core.http.rest.Response<CloseHandlesInfo>> forceCloseHandleWithResponse
(String handleId) Closes a handle on the file.generateSas
(ShareServiceSasSignatureValues shareServiceSasSignatureValues) Generates a service SAS for the file using the specifiedShareServiceSasSignatureValues
generateSas
(ShareServiceSasSignatureValues shareServiceSasSignatureValues, com.azure.core.util.Context context) Generates a service SAS for the file using the specifiedShareServiceSasSignatureValues
generateSas
(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer<String> stringToSignHandler, com.azure.core.util.Context context) Generates a service SAS for the file using the specifiedShareServiceSasSignatureValues
Get associated account name.Get the url of the storage account.Get file path of the client.Get the url of the storage file client.com.azure.core.http.HttpPipeline
Gets theHttpPipeline
powering this client.Retrieves the properties of the storage account's file.Mono
<com.azure.core.http.rest.Response<ShareFileProperties>> Retrieves the properties of the storage account's file.Mono
<com.azure.core.http.rest.Response<ShareFileProperties>> getPropertiesWithResponse
(ShareRequestConditions requestConditions) Retrieves the properties of the storage account's file.Gets the service version the client is using.Get the share name of file client.Get snapshot id which attached toShareFileAsyncClient
.com.azure.core.http.rest.PagedFlux
<HandleItem> List of open handles on a file.com.azure.core.http.rest.PagedFlux
<HandleItem> listHandles
(Integer maxResultsPerPage) List of open handles on a file.com.azure.core.http.rest.PagedFlux
<ShareFileRange> List of valid ranges for a file.com.azure.core.http.rest.PagedFlux
<ShareFileRange> listRanges
(ShareFileRange range) List of valid ranges for a file.com.azure.core.http.rest.PagedFlux
<ShareFileRange> listRanges
(ShareFileRange range, ShareRequestConditions requestConditions) List of valid ranges for a file.listRangesDiff
(String previousSnapshot) List of valid ranges for a file between the file and the specified snapshot.Mono
<com.azure.core.http.rest.Response<ShareFileRangeList>> List of valid ranges for a file.Moves the file to another location within the share.Mono
<com.azure.core.http.rest.Response<ShareFileAsyncClient>> renameWithResponse
(ShareFileRenameOptions options) Moves the file to another location within the share.setMetadata
(Map<String, String> metadata) Sets the user-defined metadata to associate to the file.Mono
<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> setMetadataWithResponse
(Map<String, String> metadata) Sets the user-defined metadata to associate to the file.Mono
<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> setMetadataWithResponse
(Map<String, String> metadata, ShareRequestConditions requestConditions) Sets the user-defined metadata to associate to the file.setProperties
(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission) Sets the user-defined file properties to associate to the file.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> setPropertiesWithResponse
(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission) Sets the user-defined file properties to associate to the file.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> setPropertiesWithResponse
(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, ShareRequestConditions requestConditions) Sets the user-defined file properties to associate to the file.Mono
<com.azure.core.http.rest.Response<ShareFileInfo>> Sets the user-defined file properties to associate to the file.upload
(Flux<ByteBuffer> data, long length) Deprecated.upload
(Flux<ByteBuffer> data, ParallelTransferOptions transferOptions) Buffers a range of bytes and uploads sub-ranges in parallel to a file in storage file service.uploadFromFile
(String uploadFilePath) Uploads file to storage file service.uploadFromFile
(String uploadFilePath, ShareRequestConditions requestConditions) Uploads file to storage file service.uploadRange
(Flux<ByteBuffer> data, long length) Uploads a range of bytes to the specified offset of a file in storage file service.uploadRangeFromUrl
(long length, long destinationOffset, long sourceOffset, String sourceUrl) Uploads a range of bytes from one file to another file.Mono
<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse
(long length, long destinationOffset, long sourceOffset, String sourceUrl) Uploads a range of bytes from one file to another file.Mono
<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse
(long length, long destinationOffset, long sourceOffset, String sourceUrl, ShareRequestConditions destinationRequestConditions) Uploads a range of bytes from one file to another file.Mono
<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> Uploads a range of bytes from one file to another file.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> Uploads a range of bytes to the specified offset of a file in storage file service.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse
(ShareFileUploadOptions options) Buffers a range of bytes and uploads sub-ranges in parallel to a file in storage file service.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse
(Flux<ByteBuffer> data, long length, Long offset) Deprecated.UseuploadRangeWithResponse(ShareFileUploadRangeOptions)
instead.Mono
<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse
(Flux<ByteBuffer> data, long length, Long offset, ShareRequestConditions requestConditions) Deprecated.UseuploadRangeWithResponse(ShareFileUploadRangeOptions)
instead.
-
Method Details
-
getAccountUrl
Get the url of the storage account.- Returns:
- the URL of the storage account
-
getFileUrl
Get the url of the storage file client.- Returns:
- the URL of the storage file client
-
getServiceVersion
Gets the service version the client is using.- Returns:
- the service version the client is using.
-
exists
Determines if the file this client represents exists in the cloud.Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
- Returns:
- Flag indicating existence of the file.
-
existsWithResponse
Determines if the file this client represents exists in the cloud.Code Samples
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
- Returns:
- Flag indicating existence of the file.
-
create
Creates a file in the storage account and returns a response ofShareFileInfo
to interact with it.Code Samples
Create the file with size 1KB.
shareFileAsyncClient.create(1024).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete creating the file!") );
For more information, see the Azure Docs.
- Parameters:
maxSize
- The maximum size in bytes for the file.- Returns:
- A response containing the file info and the status of creating the file.
- Throws:
ShareStorageException
- If the file has already existed, the parent directory does not exist or fileName is an invalid resource name.
-
beginCopy
public com.azure.core.util.polling.PollerFlux<ShareFileCopyInfo,Void> beginCopy(String sourceUrl, Map<String, String> metadata, Duration pollInterval) Copies a blob or file to a destination file within the storage account.Code Samples
Copy file from source url to the
resourcePath
PollerFlux<ShareFileCopyInfo, Void> poller = shareFileAsyncClient.beginCopy( "https://{accountName}.file.core.windows.net?{SASToken}", Collections.singletonMap("file", "metadata"), Duration.ofSeconds(2)); poller.subscribe(response -> { final ShareFileCopyInfo value = response.getValue(); System.out.printf("Copy source: %s. Status: %s.%n", value.getCopySourceUrl(), value.getCopyStatus()); }, error -> System.err.println("Error: " + error), () -> System.out.println("Complete copying the file."));
For more information, see the Azure Docs.
- Parameters:
sourceUrl
- Specifies the URL of the source file or blob, up to 2 KB in length.metadata
- Optional name-value pairs associated with the file as metadata. Metadata names must adhere to the naming rules.pollInterval
- Duration between each poll for the copy status. If none is specified, a default of one second is used.- Returns:
- A
PollerFlux
that polls the file copy operation until it has completed or has been cancelled. - See Also:
-
abortCopy
Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.Code Samples
Abort copy file from copy id("someCopyId")
shareFileAsyncClient.abortCopy("someCopyId") .doOnSuccess(response -> System.out.println("Abort copying the file completed."));
For more information, see the Azure Docs.
- Parameters:
copyId
- Specifies the copy id which has copying pending status associate with it.- Returns:
- An empty response.
-
abortCopyWithResponse
Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.Code Samples
Abort copy file from copy id("someCopyId")
shareFileAsyncClient.abortCopyWithResponse("someCopyId") .subscribe(response -> System.out.printf("Abort copying the file completed with status code %d", response.getStatusCode()));
For more information, see the Azure Docs.
- Parameters:
copyId
- Specifies the copy id which has copying pending status associate with it.- Returns:
- A response containing the status of aborting copy the file.
-
downloadToFile
Downloads a file from the system, including its metadata and properties into a file specified by the path.The file will be created and must not exist, if the file already exists a
FileAlreadyExistsException
will be thrown.Code Samples
Download the file to current folder.
shareFileAsyncClient.downloadToFile("somelocalfilepath").subscribe( response -> { if (Files.exists(Paths.get("somelocalfilepath"))) { System.out.println("Successfully downloaded the file."); } }, error -> System.err.print(error.toString()), () -> System.out.println("Complete downloading the file!") );
For more information, see the Azure Docs.
- Parameters:
downloadFilePath
- The path where store the downloaded file- Returns:
- An empty response.
-
download
Downloads a file from the system, including its metadata and propertiesCode Samples
Download the file with its metadata and properties.
shareFileAsyncClient.download().subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete downloading the data!") );
For more information, see the Azure Docs.
- Returns:
- A reactive response containing the file data.
-
delete
Deletes the file associate with the client.Code Samples
Delete the file
shareFileAsyncClient.delete().subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!") );
For more information, see the Azure Docs.
- Returns:
- An empty response
- Throws:
ShareStorageException
- If the directory doesn't exist or the file doesn't exist.
-
deleteWithResponse
Deletes the file associate with the client.Code Samples
Delete the file
shareFileAsyncClient.deleteWithResponse().subscribe( response -> System.out.println("Complete deleting the file with status code:" + response.getStatusCode()), error -> System.err.print(error.toString()) );
For more information, see the Azure Docs.
- Returns:
- A response that only contains headers and response status code
- Throws:
ShareStorageException
- If the directory doesn't exist or the file doesn't exist.
-
deleteIfExists
Deletes the file associate with the client if it exists.Code Samples
Delete the file
shareFileAsyncClient.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:
- a reactive response signaling completion.
true
indicates that the file was successfully deleted,false
indicates that the file did not exist.
-
getProperties
Retrieves the properties of the storage account's file. The properties include file metadata, last modified date, is server encrypted, and eTag.Code Samples
Retrieve file properties
shareFileAsyncClient.getProperties() .subscribe(properties -> { System.out.printf("File latest modified date is %s.", properties.getLastModified()); });
For more information, see the Azure Docs.
- Returns:
Storage file properties
-
getPropertiesWithResponse
Retrieves the properties of the storage account's file. The properties include file metadata, last modified date, is server encrypted, and eTag.Code Samples
Retrieve file properties
shareFileAsyncClient.getPropertiesWithResponse() .subscribe(response -> { ShareFileProperties properties = response.getValue(); System.out.printf("File latest modified date is %s.", properties.getLastModified()); });
For more information, see the Azure Docs.
- Returns:
- A response containing the
storage file properties
and response status code
-
setMetadata
Sets the user-defined metadata to associate to the file.If
null
is passed for the metadata it will clear the metadata associated to the file.Code Samples
Set the metadata to "file:updatedMetadata"
shareFileAsyncClient.setMetadata(Collections.singletonMap("file", "updatedMetadata")) .doOnSuccess(response -> System.out.println("Setting the file metadata completed."));
Clear the metadata of the file
shareFileAsyncClient.setMetadataWithResponse(null).subscribe( response -> System.out.printf("Setting the file metadata completed with status code %d", response.getStatusCode()));
For more information, see the Azure Docs.
- Parameters:
metadata
- Options.Metadata to set on the file, if null is passed the metadata for the file is cleared- Returns:
file meta info
- Throws:
ShareStorageException
- If the file doesn't exist or the metadata contains invalid keys
-
setMetadataWithResponse
public Mono<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String, String> metadata) Sets the user-defined metadata to associate to the file.If
null
is passed for the metadata it will clear the metadata associated to the file.Code Samples
Set the metadata to "file:updatedMetadata"
shareFileAsyncClient.setMetadataWithResponse(Collections.singletonMap("file", "updatedMetadata")) .subscribe(response -> System.out.printf("Setting the file metadata completed with status code %d", response.getStatusCode()));
Clear the metadata of the file
shareFileAsyncClient.setMetadataWithResponse(null).subscribe( response -> System.out.printf("Setting the file metadata completed with status code %d", response.getStatusCode()));
For more information, see the Azure Docs.
- Parameters:
metadata
- Options.Metadata to set on the file, if null is passed the metadata for the file is cleared- Returns:
- A response containing the
file meta info
and status code - Throws:
ShareStorageException
- If the file doesn't exist or the metadata contains invalid keys
-
upload
Deprecated.UseuploadRange(Flux, long)
instead. Or considerupload(Flux, ParallelTransferOptions)
for an upload that can handle large amounts of data.Uploads a range of bytes to the beginning of a file in storage file service. Upload operations performs an in-place write on the specified file.Code Samples
Upload data "default" to the file in Storage File Service.
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8)); shareFileAsyncClient.upload(Flux.just(defaultData), defaultData.remaining()).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!") );
For more information, see the Azure Docs.
- Parameters:
data
- The data which will upload to the storage file.length
- Specifies the number of bytes being transmitted in the request body.- Returns:
- A response that only contains headers and response status code
-
uploadWithResponse
@Deprecated public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset) Deprecated.UseuploadRangeWithResponse(ShareFileUploadRangeOptions)
instead. Or consideruploadWithResponse(ShareFileUploadOptions)
for an upload that can handle large amounts of data.Uploads a range of bytes to specific of a file in storage file service. Upload operations performs an in-place write on the specified file.Code Samples
Upload the file from 1024 to 2048 bytes with its metadata and properties and without the contentMD5.
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8)); shareFileAsyncClient.uploadWithResponse(Flux.just(defaultData), defaultData.remaining(), 0L).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!") );
For more information, see the Azure Docs.
- Parameters:
data
- The data which will upload to the storage file.length
- Specifies the number of bytes being transmitted in the request body. When the ShareFileRangeWriteType is set to clear, the value of this header must be set to zero.offset
- Optional starting point of the upload range. It will start from the beginning if it isnull
.- Returns:
- A response containing the
file upload info
with headers and response status code. - Throws:
ShareStorageException
- If you attempt to upload a range that is larger than 4 MB, the service returns status code 413 (Request Entity Too Large)
-
upload
public Mono<ShareFileUploadInfo> upload(Flux<ByteBuffer> data, ParallelTransferOptions transferOptions) Buffers a range of bytes and uploads sub-ranges in parallel to a file in storage file service. Upload operations perform an in-place write on the specified file.Code Samples
Upload data "default" to the file in Storage File Service.
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8)); shareFileAsyncClient.upload(Flux.just(defaultData), null).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!"));
For more information, see the Azure Docs.
- Parameters:
data
- The data which will upload to the storage file.transferOptions
-ParallelTransferOptions
to use to upload data.- Returns:
- The
file upload info
-
uploadRange
Uploads a range of bytes to the specified offset of a file in storage file service. Upload operations perform an in-place write on the specified file.Code Samples
Upload data "default" to the file in Storage File Service.
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8)); shareFileAsyncClient.uploadRange(Flux.just(defaultData), defaultData.remaining()).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!") );
This method does a single Put Range operation. For more information, see the Azure Docs.
- Parameters:
data
- The data which will upload to the storage file.length
- Specifies the number of bytes being transmitted in the request body.- Returns:
- The
file upload info
- Throws:
ShareStorageException
- If you attempt to upload a range that is larger than 4 MB, the service returns status code 413 (Request Entity Too Large)
-
uploadRangeFromUrl
public Mono<ShareFileUploadRangeFromUrlInfo> uploadRangeFromUrl(long length, long destinationOffset, long sourceOffset, String sourceUrl) Uploads a range of bytes from one file to another file.Code Samples
Upload a number of bytes from a file at defined source and destination offsets
shareFileAsyncClient.uploadRangeFromUrl(6, 8, 0, "sourceUrl").subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Completed upload range from url!") );
For more information, see the Azure Docs.
- Parameters:
length
- Specifies the number of bytes being transmitted in the request body.destinationOffset
- Starting point of the upload range on the destination.sourceOffset
- Starting point of the upload range on the source.sourceUrl
- Specifies the URL of the source file.- Returns:
- The
file upload range from url info
-
uploadRangeFromUrlWithResponse
public Mono<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse(long length, long destinationOffset, long sourceOffset, String sourceUrl) Uploads a range of bytes from one file to another file.Code Samples
Upload a number of bytes from a file at defined source and destination offsets
shareFileAsyncClient.uploadRangeFromUrlWithResponse(6, 8, 0, "sourceUrl").subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Completed upload range from url!") );
For more information, see the Azure Docs.
- Parameters:
length
- Specifies the number of bytes being transmitted in the request body.destinationOffset
- Starting point of the upload range on the destination.sourceOffset
- Starting point of the upload range on the source.sourceUrl
- Specifies the URL of the source file.- Returns:
- A response containing the
file upload range from url info
with headers and response status code.
-
clearRange
Clear a range of bytes to specific of a file in storage file service. Clear operations performs an in-place write on the specified file.Code Samples
Clears the first 1024 bytes.
shareFileAsyncClient.clearRange(1024).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete clearing the range!") );
For more information, see the Azure Docs.
- Parameters:
length
- Specifies the number of bytes being cleared.- Returns:
- The
file upload info
-
clearRangeWithResponse
public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> clearRangeWithResponse(long length, long offset) Clear a range of bytes to specific of a file in storage file service. Clear operations performs an in-place write on the specified file.Code Samples
Clear the range starting from 1024 with length of 1024.
shareFileAsyncClient.clearRangeWithResponse(1024, 1024).subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete clearing the range!") );
For more information, see the Azure Docs.
- Parameters:
length
- Specifies the number of bytes being cleared in the request body.offset
- Optional starting point of the upload range. It will start from the beginning if it isnull
- Returns:
- A response of
file upload info
that only contains headers and response status code.
-
uploadFromFile
Uploads file to storage file service.Code Samples
Upload the file from the source file path.
shareFileAsyncClient.uploadFromFile("someFilePath").subscribe( response -> { }, error -> System.err.print(error.toString()), () -> System.out.println("Complete deleting the file!") );
For more information, see the Azure Docs Create File and Azure Docs Upload.
- Parameters:
uploadFilePath
- The path where store the source file to upload- Returns:
- An empty response.
- Throws:
UncheckedIOException
- If an I/O error occurs.
-
listRanges
List of valid ranges for a file.Code Samples
List all ranges for the file client.
shareFileAsyncClient.listRanges().subscribe(range -> System.out.printf("List ranges completed with start: %d, end: %d", range.getStart(), range.getEnd()));
For more information, see the Azure Docs.
- Returns:
ranges
in the files.
-
listRangesDiff
List of valid ranges for a file between the file and the specified snapshot.Code Samples
final String prevSnapshot = "previoussnapshot"; shareFileAsyncClient.listRangesDiff(prevSnapshot).subscribe(response -> { System.out.println("Valid Share File Ranges are:"); for (FileRange range : response.getRanges()) { System.out.printf("Start: %s, End: %s%n", range.getStart(), range.getEnd()); } });
For more information, see the Azure Docs.
- Parameters:
previousSnapshot
- Specifies that the response will contain only ranges that were changed between target file and previous snapshot. Changed ranges include both updated and cleared ranges. The target file may be a snapshot, as long as the snapshot specified by previousSnapshot is the older of the two.- Returns:
ranges
in the files that satisfy the requirements
-
listHandles
List of open handles on a file.Code Samples
List all handles for the file client.
shareFileAsyncClient.listHandles() .subscribe(result -> System.out.printf("List handles completed with handle id %s", result.getHandleId()));
For more information, see the Azure Docs.
- Returns:
handles
in the files that satisfy the requirements
-
listHandles
List of open handles on a file.Code Samples
List 10 handles for the file client.
shareFileAsyncClient.listHandles(10) .subscribe(result -> System.out.printf("List handles completed with handle id %s", result.getHandleId()));
For more information, see the Azure Docs.
- Parameters:
maxResultsPerPage
- Optional maximum number of results will return per page- Returns:
handles
in the file that satisfy the requirements
-
forceCloseHandle
Closes a handle on the file. This is intended to be used alongsidelistHandles()
.Code Samples
Force close handles returned by list handles.
shareFileAsyncClient.listHandles().subscribe(handleItem -> shareFileAsyncClient.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:
handleId
- Handle ID to be closed.- Returns:
- A response that contains information about the closed handles.
-
forceCloseHandleWithResponse
public Mono<com.azure.core.http.rest.Response<CloseHandlesInfo>> forceCloseHandleWithResponse(String handleId) Closes a handle on the file. This is intended to be used alongsidelistHandles()
.Code Samples
Force close handles returned by list handles.
shareFileAsyncClient.listHandles().subscribe(handleItem -> shareFileAsyncClient.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:
handleId
- Handle ID to be closed.- Returns:
- A response that contains information about the closed handles along with headers and response status code.
-
forceCloseAllHandles
Closes all handles opened on the file at the service.Code Samples
Force close all handles.
shareFileAsyncClient.forceCloseAllHandles().subscribe(handlesClosedInfo -> System.out.printf("Closed %d open handles on the file.%nFailed to close %d open handles on the file%n", handlesClosedInfo.getClosedHandles(), handlesClosedInfo.getFailedHandles()));
For more information, see the Azure Docs.
- Returns:
- A response that contains information about the closed handles.
-
rename
Moves the file to another location within the share. For more information see the Azure Docs.Code Samples
ShareFileAsyncClient renamedClient = client.rename(destinationPath).block(); System.out.println("File Client has been renamed");
- Parameters:
destinationPath
- Relative path from the share to rename the file to.- Returns:
- A
Mono
containing aShareFileAsyncClient
used to interact with the new file created.
-
getFilePath
Get file path of the client.Get the file path.
String filePath = shareFileAsyncClient.getFilePath(); System.out.println("The name of the file is " + filePath);
- Returns:
- The path of the file.
-
getAccountName
Get associated account name.- Returns:
- account name associated with this storage resource.
-
getHttpPipeline
public com.azure.core.http.HttpPipeline getHttpPipeline()Gets theHttpPipeline
powering this client.- Returns:
- The pipeline.
-
uploadRange(Flux, long)
instead.