Class ShareFileAsyncClient

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

public class ShareFileAsyncClient extends Object
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 this for additional ways to construct the client.

See Also:
  • Method Details

    • getAccountUrl

      public String getAccountUrl()
      Get the url of the storage account.
      Returns:
      the URL of the storage account
    • getFileUrl

      public String getFileUrl()
      Get the url of the storage file client.
      Returns:
      the URL of the storage file client
    • getServiceVersion

      public ShareServiceVersion getServiceVersion()
      Gets the service version the client is using.
      Returns:
      the service version the client is using.
    • exists

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

      public Mono<ShareFileInfo> 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.
      Throws:
      ShareStorageException - If the file has already existed, the parent directory does not exist or fileName is an invalid resource name.
    • createWithResponse

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

      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 file info and the status of creating the file.
      Throws:
      ShareStorageException - If the directory has already existed, the parent directory does not exist or directory is an invalid resource name.
    • createWithResponse

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

      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 file info and the status of creating the file.
      Throws:
      ShareStorageException - If the directory has already existed, the parent directory does not exist or directory is an invalid resource name.
    • beginCopy

      public 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:
    • beginCopy

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

      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 that polls the file copy operation until it has completed or has been cancelled.
      See Also:
    • beginCopy

      public PollerFlux<ShareFileCopyInfo,Void> 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"));
      
       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.
      options - ShareFileCopyOptions
      Returns:
      A PollerFlux that polls the file copy operation until it has completed or has been cancelled.
      See Also:
    • abortCopy

      public Mono<Void> 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<Response<Void>> 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<Response<Void>> 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.
    • downloadToFile

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

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

      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.
    • download

      public Flux<ByteBuffer> 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.
    • downloadWithResponse

      public Mono<ShareFileDownloadAsyncResponse> 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<ShareFileDownloadAsyncResponse> 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<ShareFileDownloadAsyncResponse> 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.
    • delete

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

      public Mono<Response<Void>> 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.
    • deleteWithResponse

      public Mono<Response<Void>> 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
      Throws:
      ShareStorageException - If the directory doesn't exist or the file doesn't exist.
    • deleteIfExists

      public Mono<Boolean> 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<Response<Boolean>> 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's status code is 202, the file was successfully deleted. If status code is 404, the file does not exist.
    • getProperties

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

      public Mono<Response<ShareFileProperties>> 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
    • getPropertiesWithResponse

      public Mono<Response<ShareFileProperties>> 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 storage file properties and response status code
    • setProperties

      public Mono<ShareFileInfo> 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:
      The file info
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
    • setPropertiesWithResponse

      public Mono<Response<ShareFileInfo>> 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 file info and response status code.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
    • setPropertiesWithResponse

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

      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 file info and response status code.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
    • setMetadata

      public Mono<ShareFileMetadataInfo> setMetadata(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.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<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
    • setMetadataWithResponse

      public Mono<Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String,String> 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 file meta info and status code
      Throws:
      ShareStorageException - If the file doesn't exist or the metadata contains invalid keys
    • upload

      @Deprecated public Mono<ShareFileUploadInfo> upload(Flux<ByteBuffer> data, long length)
      Deprecated.
      Use uploadRange(Flux, long) instead. Or consider upload(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<Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset)
      Deprecated.
      Use uploadRangeWithResponse(ShareFileUploadRangeOptions) instead. Or consider uploadWithResponse(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 is null.
      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)
    • uploadWithResponse

      @Deprecated public Mono<Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset, ShareRequestConditions requestConditions)
      Deprecated.
      Use uploadRangeWithResponse(ShareFileUploadRangeOptions) instead. Or consider uploadWithResponse(ShareFileUploadOptions) 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 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
    • uploadWithResponse

      public Mono<Response<ShareFileUploadInfo>> 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:
      The file upload info
    • uploadRange

      public Mono<ShareFileUploadInfo> uploadRange(Flux<ByteBuffer> 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:
      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)
    • uploadRangeWithResponse

      public Mono<Response<ShareFileUploadInfo>> 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:
      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<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.
    • uploadRangeFromUrlWithResponse

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

      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 file upload range from url info with headers and response status code.
    • uploadRangeFromUrlWithResponse

      public Mono<Response<ShareFileUploadRangeFromUrlInfo>> 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 file upload range from url info with headers and response status code.
    • clearRange

      public Mono<ShareFileUploadInfo> 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:
      The file upload info
    • clearRangeWithResponse

      public Mono<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 is null
      Returns:
      A response of file upload info that only contains headers and response status code.
    • clearRangeWithResponse

      public Mono<Response<ShareFileUploadInfo>> 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 file upload info that only contains headers and response status code.
    • uploadFromFile

      public Mono<Void> 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.
      Throws:
      UncheckedIOException - If an I/O error occurs.
    • uploadFromFile

      public Mono<Void> 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.
      Throws:
      UncheckedIOException - If an I/O error occurs.
    • listRanges

      public PagedFlux<ShareFileRange> 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.
    • listRanges

      public PagedFlux<ShareFileRange> 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:
      ranges in the files that satisfy the requirements
    • listRanges

      public PagedFlux<ShareFileRange> 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:
      ranges in the files that satisfy the requirements
    • listRangesDiff

      public Mono<ShareFileRangeList> 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:
      ranges in the files that satisfy the requirements
    • listRangesDiffWithResponse

      public Mono<Response<ShareFileRangeList>> 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:
      options - ShareFileListRangesDiffOptions.
      Returns:
      ranges in the files that satisfy the requirements
    • listHandles

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

      public PagedFlux<HandleItem> 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:
      handles in the file that satisfy the requirements
    • forceCloseHandle

      public Mono<CloseHandlesInfo> 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<Response<CloseHandlesInfo>> 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.
    • forceCloseAllHandles

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

      public Mono<ShareFileAsyncClient> 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<Response<ShareFileAsyncClient>> 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:
      options - ShareFileRenameOptions
      Returns:
      A Mono containing a Response whose value contains a ShareFileAsyncClient used to interact with the file created.
    • 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.
    • 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.
    • 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.
    • getAccountName

      public String getAccountName()
      Get associated account name.
      Returns:
      account name associated with this storage resource.
    • getHttpPipeline

      public HttpPipeline getHttpPipeline()
      Gets the HttpPipeline powering this client.
      Returns:
      The pipeline.
    • 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.