Freigeben über


ShareFileAsyncClient Class

  • java.lang.Object
    • com.azure.storage.file.share.ShareFileAsyncClient

public class ShareFileAsyncClient

This class provides a client that contains all the operations for interacting with file in Azure Storage File Service. Operations allowed by the client are creating, copying, uploading, downloading, deleting and listing on a file, retrieving properties, setting metadata and list or force close handles of the file.

Instantiating an Asynchronous File Client

ShareFileAsyncClient client = new ShareFileClientBuilder()
     .connectionString("${connectionString}")
     .endpoint("${endpoint}")
     .buildFileAsyncClient();

View ShareFileClientBuilder for additional ways to construct the client.

Method Summary

Modifier and Type Method and Description
Mono<Void> abortCopy(String copyId)

Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.

Mono<Response<Void>> abortCopyWithResponse(String copyId)

Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.

Mono<Response<Void>> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions)

Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.

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.

PollerFlux<ShareFileCopyInfo,Void> beginCopy(String sourceUrl, ShareFileCopyOptions options, Duration pollInterval)

Copies a blob or file to a destination file within the storage account.

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.

Mono<ShareFileUploadInfo> clearRange(long length)

Clear a range of bytes to specific of a file in storage file service.

Mono<Response<ShareFileUploadInfo>> clearRangeWithResponse(long length, long offset)

Clear a range of bytes to specific of a file in storage file service.

Mono<Response<ShareFileUploadInfo>> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions)

Clear a range of bytes to specific of a file in storage file service.

Mono<ShareFileInfo> create(long maxSize)

Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.

Mono<Response<ShareFileInfo>> createWithResponse(ShareFileCreateOptions options)

Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.

Mono<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<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<Void> delete()

Deletes the file associate with the client.

Mono<Boolean> deleteIfExists()

Deletes the file associate with the client if it exists.

Mono<Response<Boolean>> deleteIfExistsWithResponse(ShareRequestConditions requestConditions)

Deletes the file associate with the client if it does not exist.

Mono<Response<Void>> deleteWithResponse()

Deletes the file associate with the client.

Mono<Response<Void>> deleteWithResponse(ShareRequestConditions requestConditions)

Deletes the file associate with the client.

Flux<ByteBuffer> download()

Downloads a file from the system, including its metadata and properties

Mono<ShareFileProperties> downloadToFile(String downloadFilePath)

Downloads a file from the system, including its metadata and properties into a file specified by the path.

Mono<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<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.

Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5)

Downloads a file from the system, including its metadata and properties

Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5, ShareRequestConditions requestConditions)

Downloads a file from the system, including its metadata and properties

Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileDownloadOptions options)

Downloads a file from the system, including its metadata and properties

Mono<Boolean> exists()

Determines if the file this client represents exists in the cloud.

Mono<Response<Boolean>> existsWithResponse()

Determines if the file this client represents exists in the cloud.

Mono<CloseHandlesInfo> forceCloseAllHandles()

Closes all handles opened on the file at the service.

Mono<CloseHandlesInfo> forceCloseHandle(String handleId)

Closes a handle on the file.

Mono<Response<CloseHandlesInfo>> forceCloseHandleWithResponse(String handleId)

Closes a handle on the file.

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)

Generates a service SAS for the file using the specified ShareServiceSasSignatureValues

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)

Generates a service SAS for the file using the specified ShareServiceSasSignatureValues

String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer<String> stringToSignHandler, Context context)

Generates a service SAS for the file using the specified ShareServiceSasSignatureValues

String getAccountName()

Get associated account name.

String getAccountUrl()

Get the url of the storage account.

String getFilePath()

Get file path of the client.

String getFileUrl()

Get the url of the storage file client.

HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Mono<ShareFileProperties> getProperties()

Retrieves the properties of the storage account's file.

Mono<Response<ShareFileProperties>> getPropertiesWithResponse()

Retrieves the properties of the storage account's file.

Mono<Response<ShareFileProperties>> getPropertiesWithResponse(ShareRequestConditions requestConditions)

Retrieves the properties of the storage account's file.

ShareServiceVersion getServiceVersion()

Gets the service version the client is using.

String getShareName()

Get the share name of file client.

String getShareSnapshotId()

Get snapshot id which attached to ShareFileAsyncClient.

PagedFlux<HandleItem> listHandles()

List of open handles on a file.

PagedFlux<HandleItem> listHandles(Integer maxResultsPerPage)

List of open handles on a file.

PagedFlux<ShareFileRange> listRanges()

List of valid ranges for a file.

PagedFlux<ShareFileRange> listRanges(ShareFileRange range)

List of valid ranges for a file.

PagedFlux<ShareFileRange> listRanges(ShareFileRange range, ShareRequestConditions requestConditions)

List of valid ranges for a file.

Mono<ShareFileRangeList> listRangesDiff(String previousSnapshot)

List of valid ranges for a file between the file and the specified snapshot.

Mono<Response<ShareFileRangeList>> listRangesDiffWithResponse(ShareFileListRangesDiffOptions options)

List of valid ranges for a file.

Mono<ShareFileAsyncClient> rename(String destinationPath)

Moves the file to another location within the share.

Mono<Response<ShareFileAsyncClient>> renameWithResponse(ShareFileRenameOptions options)

Moves the file to another location within the share.

Mono<ShareFileMetadataInfo> setMetadata(Map<String,String> metadata)

Sets the user-defined metadata to associate to the file.

Mono<Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String,String> metadata)

Sets the user-defined metadata to associate to the file.

Mono<Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String,String> metadata, ShareRequestConditions requestConditions)

Sets the user-defined metadata to associate to the file.

Mono<ShareFileInfo> setProperties(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)

Sets the user-defined file properties to associate to the file.

Mono<Response<ShareFileInfo>> setPropertiesWithResponse(ShareFileSetPropertiesOptions options)

Sets the user-defined file properties to associate to the file.

Mono<Response<ShareFileInfo>> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)

Sets the user-defined file properties to associate to the file.

Mono<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<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.

Mono<ShareFileUploadInfo> upload(Flux<ByteBuffer> data, long length)

Deprecated

Use uploadRange(Flux<ByteBuffer> data, long length) instead. Or consider upload(Flux<ByteBuffer> data, ParallelTransferOptions transferOptions) 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.

Mono<Void> uploadFromFile(String uploadFilePath)

Uploads file to storage file service.

Mono<Void> uploadFromFile(String uploadFilePath, ShareRequestConditions requestConditions)

Uploads file to storage file service.

Mono<ShareFileUploadInfo> uploadRange(Flux<ByteBuffer> data, long length)

Uploads a range of bytes to the specified offset of a file in storage file service.

Mono<ShareFileUploadRangeFromUrlInfo> uploadRangeFromUrl(long length, long destinationOffset, long sourceOffset, String sourceUrl)

Uploads a range of bytes from one file to another file.

Mono<Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options)

Uploads a range of bytes from one file to another file.

Mono<Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse(long length, long destinationOffset, long sourceOffset, String sourceUrl)

Uploads a range of bytes from one file to another file.

Mono<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<Response<ShareFileUploadInfo>> uploadRangeWithResponse(ShareFileUploadRangeOptions options)

Uploads a range of bytes to the specified offset of a file in storage file service.

Mono<Response<ShareFileUploadInfo>> uploadWithResponse(ShareFileUploadOptions options)

Buffers a range of bytes and uploads sub-ranges in parallel to a file in storage file service.

Mono<Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset)

Deprecated

Use uploadRangeWithResponse(ShareFileUploadRangeOptions options) instead. Or consider uploadWithResponse(ShareFileUploadOptions options) for an upload that can handle large amounts of data.

Uploads a range of bytes to specific of a file in storage file service.

Mono<Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset, ShareRequestConditions requestConditions)

Deprecated

Use uploadRangeWithResponse(ShareFileUploadRangeOptions options) instead. Or consider uploadWithResponse(ShareFileUploadOptions options) for an upload that can handle large amounts of data.

Uploads a range of bytes to specific offset of a file in storage file service.

Methods inherited from java.lang.Object

Method Details

abortCopy

public Mono abortCopy(String copyId)

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

public Mono> abortCopyWithResponse(String copyId)

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.

abortCopyWithResponse

public Mono> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions)

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")

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.abortCopyWithResponse("someCopyId", requestConditions)
     .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.
requestConditions - ShareRequestConditions

Returns:

A response containing the status of aborting copy the file.

beginCopy

public PollerFlux beginCopy(String sourceUrl, FileSmbProperties smbProperties, String filePermission, PermissionCopyModeType filePermissionCopyMode, Boolean ignoreReadOnly, Boolean setArchiveAttribute, Map metadata, Duration pollInterval, ShareRequestConditions destinationRequestConditions)

Copies a blob or file to a destination file within the storage account.

Code Samples

Copy file from source url to the resourcePath

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
 boolean ignoreReadOnly = false; // Default value
 boolean setArchiveAttribute = true; // Default value
 ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);

 PollerFlux<ShareFileCopyInfo, Void> poller = shareFileAsyncClient.beginCopy(
     "https://{accountName}.file.core.windows.net?{SASToken}",
     smbProperties, filePermission, PermissionCopyModeType.SOURCE, ignoreReadOnly, setArchiveAttribute,
     Collections.singletonMap("file", "metadata"), Duration.ofSeconds(2), requestConditions);

 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.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file.
filePermissionCopyMode - Mode of file permission acquisition.
ignoreReadOnly - Whether to copy despite target being read only. (default is false)
setArchiveAttribute - Whether the archive attribute is to be set on the target. (default is true)
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.
destinationRequestConditions - ShareRequestConditions

Returns:

A PollerFlux<T,U> that polls the file copy operation until it has completed or has been cancelled.

beginCopy

public PollerFlux beginCopy(String sourceUrl, ShareFileCopyOptions options, 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

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
 boolean ignoreReadOnly = false; // Default value
 boolean setArchiveAttribute = true; // Default value
 ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 CopyableFileSmbPropertiesList list = new CopyableFileSmbPropertiesList().setCreatedOn(true).setLastWrittenOn(true);
 // NOTE: FileSmbProperties and CopyableFileSmbPropertiesList should never be both set

 ShareFileCopyOptions options = new ShareFileCopyOptions()
     .setSmbProperties(smbProperties)
     .setFilePermission(filePermission)
     .setIgnoreReadOnly(ignoreReadOnly)
     .setArchiveAttribute(setArchiveAttribute)
     .setDestinationRequestConditions(requestConditions)
     .setSmbPropertiesToCopy(list)
     .setPermissionCopyModeType(PermissionCopyModeType.SOURCE)
     .setMetadata(Collections.singletonMap("file", "metadata"))
     .setFilePermissionFormat(FilePermissionFormat.BINARY);

 PollerFlux<ShareFileCopyInfo, Void> poller = shareFileAsyncClient.beginCopy(
     "https://{accountName}.file.core.windows.net?{SASToken}", options, 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.
pollInterval - Duration between each poll for the copy status. If none is specified, a default of one second is used.

Returns:

A PollerFlux<T,U> that polls the file copy operation until it has completed or has been cancelled.

beginCopy

public PollerFlux beginCopy(String sourceUrl, Map 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<T,U> that polls the file copy operation until it has completed or has been cancelled.

clearRange

public Mono clearRange(long length)

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:

clearRangeWithResponse

public Mono> 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 is null

Returns:

A response of ShareFileUploadInfo that only contains headers and response status code.

clearRangeWithResponse

public Mono> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions)

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.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.clearRangeWithResponse(1024, 1024, requestConditions).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 is null
requestConditions - ShareRequestConditions

Returns:

A response of ShareFileUploadInfo that only contains headers and response status code.

create

public Mono create(long maxSize)

Creates a file in the storage account and returns a response of ShareFileInfo 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.

createWithResponse

public Mono> createWithResponse(ShareFileCreateOptions options)

Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.

Code Samples

Create the file with length of 1024 bytes, some headers, file smb properties and metadata.

ShareFileCreateOptions options = new ShareFileCreateOptions(1024);

 options.setShareFileHttpHeaders(new ShareFileHttpHeaders()
     .setContentType("text/html")
     .setContentEncoding("gzip")
     .setContentLanguage("en")
     .setCacheControl("no-transform")
     .setContentDisposition("attachment"));
 options.setSmbProperties(new FileSmbProperties()
     .setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
     .setFileCreationTime(OffsetDateTime.now())
     .setFileLastWriteTime(OffsetDateTime.now())
     .setFilePermissionKey("filePermissionKey"));
 options.setFilePermission("filePermission");
 options.setFilePermissionFormat(FilePermissionFormat.BINARY);
 options.setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId));
 options.setMetadata(Collections.singletonMap("directory", "metadata"));

 shareFileAsyncClient.createWithResponse(options)
     .subscribe(response -> System.out.printf("Creating the file completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

Returns:

A response containing the ShareFileInfo and the status of creating the file.

createWithResponse

public Mono> createWithResponse(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata)

Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.

Code Samples

Create the file with length of 1024 bytes, some headers, file smb properties and metadata.

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
 shareFileAsyncClient.createWithResponse(1024, httpHeaders, smbProperties, filePermission,
     Collections.singletonMap("directory", "metadata"))
     .subscribe(response -> System.out.printf("Creating the file completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

maxSize - The maximum size in bytes for the file.
httpHeaders - 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.

Returns:

A response containing the ShareFileInfo and the status of creating the file.

createWithResponse

public Mono> createWithResponse(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map metadata, ShareRequestConditions requestConditions)

Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.

Code Samples

Create the file with length of 1024 bytes, some headers, file smb properties and metadata.

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);

 shareFileAsyncClient.createWithResponse(1024, httpHeaders, smbProperties, filePermission,
     Collections.singletonMap("directory", "metadata"), requestConditions)
     .subscribe(response -> System.out.printf("Creating the file completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

maxSize - The maximum size in bytes for the file.
httpHeaders - 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 - ShareRequestConditions

Returns:

A response containing the ShareFileInfo and the status of creating the file.

delete

public Mono 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

deleteIfExists

public Mono 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.

deleteIfExistsWithResponse

public Mono> deleteIfExistsWithResponse(ShareRequestConditions requestConditions)

Deletes the file associate with the client if it does not exist.

Code Samples

Delete the file

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.deleteIfExistsWithResponse(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:

requestConditions - ShareRequestConditions

Returns:

A reactive response signaling completion. If Response<T>'s status code is 202, the file was successfully deleted. If status code is 404, the file does not exist.

deleteWithResponse

public Mono> 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

deleteWithResponse

public Mono> deleteWithResponse(ShareRequestConditions requestConditions)

Deletes the file associate with the client.

Code Samples

Delete the file

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.deleteWithResponse(requestConditions).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.

Parameters:

requestConditions - ShareRequestConditions

Returns:

A response that only contains headers and response status code

download

public Flux download()

Downloads a file from the system, including its metadata and properties

Code 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.

downloadToFile

public Mono downloadToFile(String downloadFilePath)

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.

downloadToFileWithResponse

public Mono> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range)

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 from 1024 to 2048 bytes to current folder.

shareFileAsyncClient.downloadToFileWithResponse("somelocalfilepath", new ShareFileRange(1024, 2047L))
     .subscribe(
         response -> {
             if (Files.exists(Paths.get("somelocalfilepath"))) {
                 System.out.println("Successfully downloaded the file with status code "
                     + response.getStatusCode());
             }
         },
         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
range - Optional byte range which returns file data only from the specified range.

Returns:

An empty response.

downloadToFileWithResponse

public Mono> 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.

The file will be created and must not exist, if the file already exists a FileAlreadyExistsException will be thrown.

Code Samples

Download the file from 1024 to 2048 bytes to current folder.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.downloadToFileWithResponse("somelocalfilepath", new ShareFileRange(1024, 2047L),
     requestConditions)
     .subscribe(
         response -> {
             if (Files.exists(Paths.get("somelocalfilepath"))) {
                 System.out.println("Successfully downloaded the file with status code "
                     + response.getStatusCode());
             }
         },
         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
range - Optional byte range which returns file data only from the specified range.
requestConditions - ShareRequestConditions

Returns:

An empty response.

downloadWithResponse

public Mono downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5)

Downloads a file from the system, including its metadata and properties

Code Samples

Download the file from 1024 to 2048 bytes with its metadata and properties and without the contentMD5.

shareFileAsyncClient.downloadWithResponse(new ShareFileRange(1024, 2047L), false)
     .subscribe(response ->
             System.out.printf("Complete downloading the data with status code %d%n", response.getStatusCode()),
         error -> System.err.println(error.getMessage())
     );

For more information, see the Azure Docs.

Parameters:

range - Optional byte range which returns file data only from the specified range.
rangeGetContentMD5 - Optional boolean which the service returns the MD5 hash for the range when it sets to true, as long as the range is less than or equal to 4 MB in size.

Returns:

A reactive response containing response data and the file data.

downloadWithResponse

public Mono downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5, ShareRequestConditions requestConditions)

Downloads a file from the system, including its metadata and properties

Code Samples

Download the file from 1024 to 2048 bytes with its metadata and properties and without the contentMD5.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.downloadWithResponse(new ShareFileRange(1024, 2047L), false, requestConditions)
     .subscribe(response ->
             System.out.printf("Complete downloading the data with status code %d%n", response.getStatusCode()),
         error -> System.err.println(error.getMessage())
     );

For more information, see the Azure Docs.

Parameters:

range - Optional byte range which returns file data only from the specified range.
rangeGetContentMD5 - Optional boolean which the service returns the MD5 hash for the range when it sets to
requestConditions - ShareRequestConditions true, as long as the range is less than or equal to 4 MB in size.

Returns:

A reactive response containing response data and the file data.

downloadWithResponse

public Mono downloadWithResponse(ShareFileDownloadOptions options)

Downloads a file from the system, including its metadata and properties

Code Samples

Download the file from 1024 to 2048 bytes with its metadata and properties and without the contentMD5.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 ShareFileRange range = new ShareFileRange(1024, 2047L);
 DownloadRetryOptions retryOptions = new DownloadRetryOptions().setMaxRetryRequests(3);
 ShareFileDownloadOptions options = new ShareFileDownloadOptions().setRange(range)
     .setRequestConditions(requestConditions)
     .setRangeContentMd5Requested(false)
     .setRetryOptions(retryOptions);
 shareFileAsyncClient.downloadWithResponse(options)
     .subscribe(response ->
             System.out.printf("Complete downloading the data with status code %d%n", response.getStatusCode()),
         error -> System.err.println(error.getMessage())
     );

For more information, see the Azure Docs.

Parameters:

options - ShareFileDownloadOptions true, as long as the range is less than or equal to 4 MB in size.

Returns:

A reactive response containing response data and the file data.

exists

public Mono 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

public Mono> 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.

forceCloseAllHandles

public Mono 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.

forceCloseHandle

public Mono forceCloseHandle(String handleId)

Closes a handle on the file. This is intended to be used alongside listHandles().

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> forceCloseHandleWithResponse(String handleId)

Closes a handle on the file. This is intended to be used alongside listHandles().

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.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)

Generates a service SAS for the file 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());

 shareFileAsyncClient.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Context context)

Generates a service SAS for the file 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
 shareFileAsyncClient.generateSas(values, new Context("key", "value"));

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

generateSas

public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer stringToSignHandler, Context context)

Generates a service SAS for the file using the specified ShareServiceSasSignatureValues

Note : The client must be authenticated via StorageSharedKeyCredential

See ShareServiceSasSignatureValues for more information on how to construct a service SAS.

Parameters:

shareServiceSasSignatureValues - ShareServiceSasSignatureValues
stringToSignHandler - For debugging purposes only. Returns the string to sign that was used to generate the signature.
context - Additional context that is passed through the code when generating a SAS.

Returns:

A String representing the SAS query parameters.

getAccountName

public String getAccountName()

Get associated account name.

Returns:

account name associated with this storage resource.

getAccountUrl

public String getAccountUrl()

Get the url of the storage account.

Returns:

the URL of the storage account

getFilePath

public String 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.

getFileUrl

public String getFileUrl()

Get the url of the storage file client.

Returns:

the URL of the storage file client

getHttpPipeline

public HttpPipeline getHttpPipeline()

Gets the HttpPipeline powering this client.

Returns:

The pipeline.

getProperties

public Mono 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:

getPropertiesWithResponse

public Mono> 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 ShareFileProperties and response status code

getPropertiesWithResponse

public Mono> getPropertiesWithResponse(ShareRequestConditions requestConditions)

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

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.getPropertiesWithResponse(requestConditions)
     .subscribe(response -> {
         ShareFileProperties properties = response.getValue();
         System.out.printf("File latest modified date is %s.", properties.getLastModified());
     });

For more information, see the Azure Docs.

Parameters:

requestConditions - ShareRequestConditions

Returns:

A response containing the ShareFileProperties and response status code

getServiceVersion

public ShareServiceVersion getServiceVersion()

Gets the service version the client is using.

Returns:

the service version the client is using.

getShareName

public String getShareName()

Get the share name of file client.

Get the share name.

String shareName = directoryAsyncClient.getShareName();
 System.out.println("The share name of the directory is " + shareName);

Returns:

The share name of the file.

getShareSnapshotId

public String getShareSnapshotId()

Get snapshot id which attached to ShareFileAsyncClient. Return null if no snapshot id attached.

Code Samples

Get the share snapshot id.

OffsetDateTime currentTime = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC);
 ShareFileAsyncClient shareFileAsyncClient = new ShareFileClientBuilder()
     .endpoint("https://${accountName}.file.core.windows.net")
     .sasToken("${SASToken}")
     .shareName("myshare")
     .resourcePath("myfiile")
     .snapshot(currentTime.toString())
     .buildFileAsyncClient();

 System.out.printf("Snapshot ID: %s%n", shareFileAsyncClient.getShareSnapshotId());

Returns:

The snapshot id which is a unique DateTime value that identifies the share snapshot to its base share.

listHandles

public PagedFlux 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:

HandleItem in the files that satisfy the requirements

listHandles

public PagedFlux listHandles(Integer maxResultsPerPage)

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:

HandleItem in the file that satisfy the requirements

listRanges

public PagedFlux 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:

ShareFileRange in the files.

listRanges

public PagedFlux listRanges(ShareFileRange range)

List of valid ranges for a file.

Code Samples

List all ranges within the file range from 1KB to 2KB.

shareFileAsyncClient.listRanges(new ShareFileRange(1024, 2048L))
     .subscribe(result -> System.out.printf("List ranges completed with start: %d, end: %d",
         result.getStart(), result.getEnd()));

For more information, see the Azure Docs.

Parameters:

range - Optional byte range which returns file data only from the specified range.

Returns:

ShareFileRange in the files that satisfy the requirements

listRanges

public PagedFlux listRanges(ShareFileRange range, ShareRequestConditions requestConditions)

List of valid ranges for a file.

Code Samples

List all ranges within the file range from 1KB to 2KB.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.listRanges(new ShareFileRange(1024, 2048L), requestConditions)
     .subscribe(result -> System.out.printf("List ranges completed with start: %d, end: %d",
         result.getStart(), result.getEnd()));

For more information, see the Azure Docs.

Parameters:

range - Optional byte range which returns file data only from the specified range.
requestConditions - ShareRequestConditions

Returns:

ShareFileRange in the files that satisfy the requirements

listRangesDiff

public Mono listRangesDiff(String previousSnapshot)

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:

ShareFileRange in the files that satisfy the requirements

listRangesDiffWithResponse

public Mono> listRangesDiffWithResponse(ShareFileListRangesDiffOptions options)

List of valid ranges for a file.

Code Samples

List all ranges within the file range from 1KB to 2KB.

shareFileAsyncClient.listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("previoussnapshot")
     .setRange(new ShareFileRange(1024, 2048L))).subscribe(response -> {
         System.out.println("Valid Share File Ranges are:");
         for (FileRange range : response.getValue().getRanges()) {
             System.out.printf("Start: %s, End: %s%n", range.getStart(), range.getEnd());
         }
     });

For more information, see the Azure Docs.

Parameters:

Returns:

ShareFileRange in the files that satisfy the requirements

rename

public Mono rename(String destinationPath)

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 a ShareFileAsyncClient used to interact with the new file created.

renameWithResponse

public Mono> renameWithResponse(ShareFileRenameOptions options)

Moves the file 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);

 ShareFileAsyncClient newRenamedClient = client.renameWithResponse(options).block().getValue();
 System.out.println("File Client has been renamed");

Parameters:

Returns:

A Mono containing a Response<T> whose value contains a ShareFileAsyncClient used to interact with the file created.

setMetadata

public Mono setMetadata(Map 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.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:

setMetadataWithResponse

public Mono> setMetadataWithResponse(Map 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 ShareFileMetadataInfo and status code

setMetadataWithResponse

public Mono> setMetadataWithResponse(Map metadata, ShareRequestConditions requestConditions)

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"

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.setMetadataWithResponse(Collections.singletonMap("file", "updatedMetadata"), requestConditions)
     .subscribe(response -> System.out.printf("Setting the file metadata completed with status code %d",
         response.getStatusCode()));

Clear the metadata of the file

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.setMetadataWithResponse(null, requestConditions).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
requestConditions - ShareRequestConditions

Returns:

A response containing the ShareFileMetadataInfo and status code

setProperties

public Mono setProperties(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)

Sets the user-defined file properties to associate to the file.

If null is passed for the fileProperties.httpHeaders it will clear the httpHeaders associated to the file. If null is passed for the fileProperties.filesmbproperties it will preserve the filesmb properties associated with the file.

Code Samples

Set the httpHeaders of contentType of "text/plain"

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
 shareFileAsyncClient.setProperties(1024, httpHeaders, smbProperties, filePermission)
     .doOnSuccess(response -> System.out.println("Setting the file properties completed."));

Clear the metadata of the file and preserve the SMB properties

shareFileAsyncClient.setProperties(1024, null, null, null)
     .subscribe(response -> System.out.println("Setting the file httpHeaders completed."));

For more information, see the Azure Docs.

Parameters:

newFileSize - New file size of the file
httpHeaders - The user settable file http headers.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file

Returns:

setPropertiesWithResponse

public Mono> setPropertiesWithResponse(ShareFileSetPropertiesOptions options)

Sets the user-defined file properties to associate to the file.

If null is passed for the httpHeaders it will clear the httpHeaders associated to the file. If null is passed for the filesmbproperties it will preserve the filesmbproperties associated with the file.

Code Samples

Set the httpHeaders of contentType of "text/plain"

ShareFileSetPropertiesOptions options = new ShareFileSetPropertiesOptions(1024);

 options.setHttpHeaders(new ShareFileHttpHeaders()
     .setContentType("text/html")
     .setContentEncoding("gzip")
     .setContentLanguage("en")
     .setCacheControl("no-transform")
     .setContentDisposition("attachment"));
 options.setSmbProperties(new FileSmbProperties()
     .setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
     .setFileCreationTime(OffsetDateTime.now())
     .setFileLastWriteTime(OffsetDateTime.now())
     .setFilePermissionKey("filePermissionKey"));
 options.setFilePermissions(new ShareFilePermission().setPermission("filePermission")
     .setPermissionFormat(FilePermissionFormat.BINARY));
 options.setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId));

 // NOTE: filePermission and filePermissionKey should never be both set
 shareFileAsyncClient.setPropertiesWithResponse(options)
     .subscribe(response -> System.out.printf("Setting the file properties completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

Returns:

Response containing the ShareFileInfo and response status code.

setPropertiesWithResponse

public Mono> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)

Sets the user-defined file properties to associate to the file.

If null is passed for the httpHeaders it will clear the httpHeaders associated to the file. If null is passed for the filesmbproperties it will preserve the filesmbproperties associated with the file.

Code Samples

Set the httpHeaders of contentType of "text/plain"

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
 shareFileAsyncClient.setPropertiesWithResponse(1024, httpHeaders, smbProperties, filePermission)
     .subscribe(response -> System.out.printf("Setting the file properties completed with status code %d",
         response.getStatusCode()));

Clear the metadata of the file and preserve the SMB properties

shareFileAsyncClient.setPropertiesWithResponse(1024, null, null, null)
     .subscribe(response -> System.out.printf("Setting the file httpHeaders completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

newFileSize - New file size of the file.
httpHeaders - The user settable file http headers.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file.

Returns:

Response containing the ShareFileInfo and response status code.

setPropertiesWithResponse

public Mono> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, ShareRequestConditions requestConditions)

Sets the user-defined file properties to associate to the file.

If null is passed for the httpHeaders it will clear the httpHeaders associated to the file. If null is passed for the filesmbproperties it will preserve the filesmbproperties associated with the file.

Code Samples

Set the httpHeaders of contentType of "text/plain"

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);
 shareFileAsyncClient.setPropertiesWithResponse(1024, httpHeaders, smbProperties, filePermission, requestConditions)
     .subscribe(response -> System.out.printf("Setting the file properties completed with status code %d",
         response.getStatusCode()));

Clear the metadata of the file and preserve the SMB properties

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.setPropertiesWithResponse(1024, null, null, null, requestConditions)
     .subscribe(response -> System.out.printf("Setting the file httpHeaders completed with status code %d",
         response.getStatusCode()));

For more information, see the Azure Docs.

Parameters:

newFileSize - New file size of the file.
httpHeaders - The user settable file http headers.
smbProperties - The user settable file smb properties.
filePermission - The file permission of the file.
requestConditions - ShareRequestConditions

Returns:

Response containing the ShareFileInfo and response status code.

upload

public Mono upload(Flux 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:

upload

@Deprecated
public Mono upload(Flux data, long length)

Deprecated

Use uploadRange(Flux<ByteBuffer> data, long length) instead. Or consider upload(Flux<ByteBuffer> data, ParallelTransferOptions transferOptions) 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

uploadFromFile

public Mono uploadFromFile(String uploadFilePath)

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.

uploadFromFile

public Mono uploadFromFile(String uploadFilePath, ShareRequestConditions requestConditions)

Uploads file to storage file service.

Code Samples

Upload the file from the source file path.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.uploadFromFile("someFilePath", requestConditions).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
requestConditions - ShareRequestConditions

Returns:

An empty response.

uploadRange

public Mono uploadRange(Flux data, long length)

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:

uploadRangeFromUrl

public Mono 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:

uploadRangeFromUrlWithResponse

public Mono> uploadRangeFromUrlWithResponse(ShareFileUploadRangeFromUrlOptions options)

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(
     new ShareFileUploadRangeFromUrlOptions(6, "sourceUrl").setDestinationOffset(8))
     .subscribe(
         response -> { },
         error -> System.err.print(error.toString()),
         () -> System.out.println("Completed upload range from url!"));

For more information, see the Azure Docs.

Parameters:

options - argument collection

Returns:

A response containing the ShareFileUploadRangeFromUrlInfo with headers and response status code.

uploadRangeFromUrlWithResponse

public Mono> 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 ShareFileUploadRangeFromUrlInfo with headers and response status code.

uploadRangeFromUrlWithResponse

public Mono> uploadRangeFromUrlWithResponse(long length, long destinationOffset, long sourceOffset, String sourceUrl, ShareRequestConditions destinationRequestConditions)

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

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 shareFileAsyncClient.uploadRangeFromUrlWithResponse(6, 8, 0, "sourceUrl", requestConditions).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.
destinationRequestConditions - ShareRequestConditions

Returns:

A response containing the ShareFileUploadRangeFromUrlInfo with headers and response status code.

uploadRangeWithResponse

public Mono> uploadRangeWithResponse(ShareFileUploadRangeOptions options)

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.uploadRangeWithResponse(new ShareFileUploadRangeOptions(
     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:

options - Argument collection for the upload operation.

Returns:

uploadWithResponse

public Mono> uploadWithResponse(ShareFileUploadOptions options)

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.uploadWithResponse(new ShareFileUploadOptions(
     Flux.just(defaultData))).subscribe(
         response -> { },
         error -> System.err.print(error.toString()),
         () -> System.out.println("Complete deleting the file!")
 );

For more information, see the Azure Docs.

Parameters:

options - Argument collection for the upload operation.

Returns:

uploadWithResponse

@Deprecated
public Mono> uploadWithResponse(Flux data, long length, Long offset)

Deprecated

Use uploadRangeWithResponse(ShareFileUploadRangeOptions options) instead. Or consider uploadWithResponse(ShareFileUploadOptions options) 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 is null.

Returns:

A response containing the ShareFileUploadInfo with headers and response status code.

uploadWithResponse

@Deprecated
public Mono> uploadWithResponse(Flux data, long length, Long offset, ShareRequestConditions requestConditions)

Deprecated

Use uploadRangeWithResponse(ShareFileUploadRangeOptions options) instead. Or consider uploadWithResponse(ShareFileUploadOptions options) for an upload that can handle large amounts of data.

Uploads a range of bytes to specific offset 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.

ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
 ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8));
 shareFileAsyncClient.uploadWithResponse(Flux.just(defaultData), defaultData.remaining(), 0L, requestConditions)
     .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 is null.
requestConditions - ShareRequestConditions

Returns:

A response containing the ShareFileUploadInfo with headers and response status code.

Applies to