public class ShareFileAsyncClient extends Object
Instantiating an Asynchronous File Client
ShareFileAsyncClient client = new ShareFileClientBuilder() .connectionString("${connectionString}") .endpoint("${endpoint}") .buildFileAsyncClient();
View this
for additional ways to construct the client.
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<com.azure.core.http.rest.Response<Void>> |
abortCopyWithResponse(String copyId)
Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.
|
Mono<com.azure.core.http.rest.Response<Void>> |
abortCopyWithResponse(String copyId,
ShareRequestConditions requestConditions)
Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata.
|
com.azure.core.util.polling.PollerFlux<ShareFileCopyInfo,Void> |
beginCopy(String sourceUrl,
FileSmbProperties smbProperties,
String filePermission,
PermissionCopyModeType filePermissionCopyMode,
Boolean ignoreReadOnly,
Boolean setArchiveAttribute,
Map<String,String> metadata,
Duration pollInterval,
ShareRequestConditions destinationRequestConditions)
Copies a blob or file to a destination file within the storage account.
|
com.azure.core.util.polling.PollerFlux<ShareFileCopyInfo,Void> |
beginCopy(String sourceUrl,
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<com.azure.core.http.rest.Response<ShareFileUploadInfo>> |
clearRangeWithResponse(long length,
long offset)
Clear a range of bytes to specific of a file in storage file service.
|
Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> |
clearRangeWithResponse(long length,
long offset,
ShareRequestConditions requestConditions)
Clear a range of bytes to specific of a file in storage file service.
|
Mono<ShareFileInfo> |
create(long maxSize)
Creates a file in the storage account and returns a response of
ShareFileInfo to interact with it. |
Mono<com.azure.core.http.rest.Response<ShareFileInfo>> |
createWithResponse(long maxSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata)
Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.
|
Mono<com.azure.core.http.rest.Response<ShareFileInfo>> |
createWithResponse(long maxSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata,
ShareRequestConditions requestConditions)
Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.
|
Mono<Void> |
delete()
Deletes the file associate with the client.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteWithResponse()
Deletes the file associate with the client.
|
Mono<com.azure.core.http.rest.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<com.azure.core.http.rest.Response<ShareFileProperties>> |
downloadToFileWithResponse(String downloadFilePath,
ShareFileRange range)
Downloads a file from the system, including its metadata and properties into a file specified by the path.
|
Mono<com.azure.core.http.rest.Response<ShareFileProperties>> |
downloadToFileWithResponse(String downloadFilePath,
ShareFileRange range,
ShareRequestConditions requestConditions)
Downloads a file from the system, including its metadata and properties into a file specified by the path.
|
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<Boolean> |
exists()
Determines if the file this client represents exists in the cloud.
|
Mono<com.azure.core.http.rest.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<com.azure.core.http.rest.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
Note : The client must be authenticated via StorageSharedKeyCredential |
String |
getAccountName()
Get associated account name.
|
String |
getFilePath()
Get file path of the client.
|
String |
getFileUrl()
Get the url of the storage file client.
|
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
Mono<ShareFileProperties> |
getProperties()
Retrieves the properties of the storage account's file.
|
Mono<com.azure.core.http.rest.Response<ShareFileProperties>> |
getPropertiesWithResponse()
Retrieves the properties of the storage account's file.
|
Mono<com.azure.core.http.rest.Response<ShareFileProperties>> |
getPropertiesWithResponse(ShareRequestConditions requestConditions)
Retrieves the properties of the storage account's file.
|
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 . |
com.azure.core.http.rest.PagedFlux<HandleItem> |
listHandles()
List of open handles on a file.
|
com.azure.core.http.rest.PagedFlux<HandleItem> |
listHandles(Integer maxResultsPerPage)
List of open handles on a file.
|
com.azure.core.http.rest.PagedFlux<ShareFileRange> |
listRanges()
List of valid ranges for a file.
|
com.azure.core.http.rest.PagedFlux<ShareFileRange> |
listRanges(ShareFileRange range)
List of valid ranges for a file.
|
com.azure.core.http.rest.PagedFlux<ShareFileRange> |
listRanges(ShareFileRange range,
ShareRequestConditions requestConditions)
List of valid ranges for a file.
|
Mono<ShareFileRangeList> |
listRangesDiff(String previousSnapshot)
List of valid ranges for a file between the file and the specified snapshot.
|
Mono<com.azure.core.http.rest.Response<ShareFileRangeList>> |
listRangesDiffWithResponse(ShareFileListRangesDiffOptions options)
List of valid ranges for a file.
|
Mono<ShareFileMetadataInfo> |
setMetadata(Map<String,String> metadata)
Sets the user-defined metadata to associate to the file.
|
Mono<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> |
setMetadataWithResponse(Map<String,String> metadata)
Sets the user-defined metadata to associate to the file.
|
Mono<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> |
setMetadataWithResponse(Map<String,String> metadata,
ShareRequestConditions requestConditions)
Sets the user-defined metadata to associate to the file.
|
Mono<ShareFileInfo> |
setProperties(long newFileSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission)
Sets the user-defined file properties to associate to the file.
|
Mono<com.azure.core.http.rest.Response<ShareFileInfo>> |
setPropertiesWithResponse(long newFileSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission)
Sets the user-defined file properties to associate to the file.
|
Mono<com.azure.core.http.rest.Response<ShareFileInfo>> |
setPropertiesWithResponse(long newFileSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission,
ShareRequestConditions requestConditions)
Sets the user-defined file properties to associate to the file.
|
Mono<ShareFileUploadInfo> |
upload(Flux<ByteBuffer> data,
long length)
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<ShareFileUploadRangeFromUrlInfo> |
uploadRangeFromUrl(long length,
long destinationOffset,
long sourceOffset,
String sourceUrl)
Uploads a range of bytes from one file to another file.
|
Mono<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> |
uploadRangeFromUrlWithResponse(long length,
long destinationOffset,
long sourceOffset,
String sourceUrl)
Uploads a range of bytes from one file to another file.
|
Mono<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> |
uploadRangeFromUrlWithResponse(long length,
long destinationOffset,
long sourceOffset,
String sourceUrl,
ShareRequestConditions destinationRequestConditions)
Uploads a range of bytes from one file to another file.
|
Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> |
uploadWithResponse(Flux<ByteBuffer> data,
long length,
Long offset)
Uploads a range of bytes to specific of a file in storage file service.
|
Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> |
uploadWithResponse(Flux<ByteBuffer> data,
long length,
Long offset,
ShareRequestConditions requestConditions)
Uploads a range of bytes to specific of a file in storage file service.
|
public String getFileUrl()
public ShareServiceVersion getServiceVersion()
public Mono<Boolean> exists()
Code Samples
client.exists().subscribe(response -> System.out.printf("Exists? %b%n", response));
public Mono<com.azure.core.http.rest.Response<Boolean>> existsWithResponse()
Code Samples
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.getValue()));
public Mono<ShareFileInfo> create(long maxSize)
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.
maxSize
- The maximum size in bytes for the file.ShareStorageException
- If the file has already existed, the parent directory does not exist or fileName
is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareFileInfo>> createWithResponse(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata)
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.
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.file info
and the status of creating the file.ShareStorageException
- If the directory has already existed, the parent directory does not exist or
directory is an invalid resource name.public Mono<com.azure.core.http.rest.Response<ShareFileInfo>> createWithResponse(long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions)
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.
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
file info
and the status of creating the file.ShareStorageException
- If the directory has already existed, the parent directory does not exist or
directory is an invalid resource name.public com.azure.core.util.polling.PollerFlux<ShareFileCopyInfo,Void> beginCopy(String sourceUrl, Map<String,String> metadata, Duration pollInterval)
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.
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.PollerFlux
that polls the file copy operation until it has completed or has been cancelled.public com.azure.core.util.polling.PollerFlux<ShareFileCopyInfo,Void> beginCopy(String sourceUrl, FileSmbProperties smbProperties, String filePermission, PermissionCopyModeType filePermissionCopyMode, Boolean ignoreReadOnly, Boolean setArchiveAttribute, Map<String,String> metadata, Duration pollInterval, ShareRequestConditions destinationRequestConditions)
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.
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 or not to copy despite target being read only. (default is false)setArchiveAttribute
- Whether or not 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
PollerFlux
that polls the file copy operation until it has completed or has been cancelled.public Mono<Void> abortCopy(String copyId)
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.
copyId
- Specifies the copy id which has copying pending status associate with it.public Mono<com.azure.core.http.rest.Response<Void>> abortCopyWithResponse(String copyId)
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.
copyId
- Specifies the copy id which has copying pending status associate with it.public Mono<com.azure.core.http.rest.Response<Void>> abortCopyWithResponse(String copyId, ShareRequestConditions requestConditions)
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.
copyId
- Specifies the copy id which has copying pending status associate with it.requestConditions
- ShareRequestConditions
public Mono<ShareFileProperties> downloadToFile(String downloadFilePath)
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.
downloadFilePath
- The path where store the downloaded filepublic Mono<com.azure.core.http.rest.Response<ShareFileProperties>> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range)
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.
downloadFilePath
- The path where store the downloaded filerange
- Optional byte range which returns file data only from the specified range.public Mono<com.azure.core.http.rest.Response<ShareFileProperties>> downloadToFileWithResponse(String downloadFilePath, ShareFileRange range, ShareRequestConditions requestConditions)
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.
downloadFilePath
- The path where store the downloaded filerange
- Optional byte range which returns file data only from the specified range.requestConditions
- ShareRequestConditions
public Flux<ByteBuffer> download()
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.
public Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5)
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.
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.public Mono<ShareFileDownloadAsyncResponse> downloadWithResponse(ShareFileRange range, Boolean rangeGetContentMD5, ShareRequestConditions requestConditions)
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.
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 torequestConditions
- ShareRequestConditions
true, as long as the range is less than or equal to 4 MB in size.public Mono<Void> delete()
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.
ShareStorageException
- If the directory doesn't exist or the file doesn't exist.public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse()
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.
ShareStorageException
- If the directory doesn't exist or the file doesn't exist.public Mono<com.azure.core.http.rest.Response<Void>> deleteWithResponse(ShareRequestConditions requestConditions)
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.
requestConditions
- ShareRequestConditions
ShareStorageException
- If the directory doesn't exist or the file doesn't exist.public Mono<ShareFileProperties> getProperties()
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.
Storage file properties
public Mono<com.azure.core.http.rest.Response<ShareFileProperties>> getPropertiesWithResponse()
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.
storage file properties
and response status codepublic Mono<com.azure.core.http.rest.Response<ShareFileProperties>> getPropertiesWithResponse(ShareRequestConditions requestConditions)
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.
requestConditions
- ShareRequestConditions
storage file properties
and response status codepublic Mono<ShareFileInfo> setProperties(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)
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.
newFileSize
- New file size of the filehttpHeaders
- The user settable file http headers.smbProperties
- The user settable file smb properties.filePermission
- The file permission of the filefile info
IllegalArgumentException
- thrown if parameters fail the validation.public Mono<com.azure.core.http.rest.Response<ShareFileInfo>> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission)
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.
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.file info
and response status code.IllegalArgumentException
- thrown if parameters fail the validation.public Mono<com.azure.core.http.rest.Response<ShareFileInfo>> setPropertiesWithResponse(long newFileSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, ShareRequestConditions requestConditions)
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.
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
file info
and response status code.IllegalArgumentException
- thrown if parameters fail the validation.public Mono<ShareFileMetadataInfo> setMetadata(Map<String,String> metadata)
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.
metadata
- Options.Metadata to set on the file, if null is passed the metadata for the file is clearedfile meta info
ShareStorageException
- If the file doesn't exist or the metadata contains invalid keyspublic Mono<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String,String> metadata)
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.
metadata
- Options.Metadata to set on the file, if null is passed the metadata for the file is clearedfile meta info
and status codeShareStorageException
- If the file doesn't exist or the metadata contains invalid keyspublic Mono<com.azure.core.http.rest.Response<ShareFileMetadataInfo>> setMetadataWithResponse(Map<String,String> metadata, ShareRequestConditions requestConditions)
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.
metadata
- Options.Metadata to set on the file, if null is passed the metadata for the file is clearedrequestConditions
- ShareRequestConditions
file meta info
and status codeShareStorageException
- If the file doesn't exist or the metadata contains invalid keyspublic Mono<ShareFileUploadInfo> upload(Flux<ByteBuffer> data, long length)
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.
data
- The data which will upload to the storage file.length
- Specifies the number of bytes being transmitted in the request body.public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset)
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.
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
.file upload info
with headers and response
status code.ShareStorageException
- If you attempt to upload a range that is larger than 4 MB, the service returns
status code 413 (Request Entity Too Large)public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> uploadWithResponse(Flux<ByteBuffer> data, long length, Long offset, ShareRequestConditions requestConditions)
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.
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
file upload info
with headers and response
status code.ShareStorageException
- If you attempt to upload a range that is larger than 4 MB, the service returns
status code 413 (Request Entity Too Large)public Mono<ShareFileUploadRangeFromUrlInfo> uploadRangeFromUrl(long length, long destinationOffset, long sourceOffset, String sourceUrl)
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.
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.file upload range from url info
public Mono<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse(long length, long destinationOffset, long sourceOffset, String sourceUrl)
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.
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.file upload range from url info
with
headers and response status code.public Mono<com.azure.core.http.rest.Response<ShareFileUploadRangeFromUrlInfo>> uploadRangeFromUrlWithResponse(long length, long destinationOffset, long sourceOffset, String sourceUrl, ShareRequestConditions destinationRequestConditions)
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.
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
file upload range from url info
with
headers and response status code.public Mono<ShareFileUploadInfo> clearRange(long length)
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.
length
- Specifies the number of bytes being cleared.file upload info
public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> clearRangeWithResponse(long length, long offset)
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.
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
file upload info
that only contains headers and response
status code.public Mono<com.azure.core.http.rest.Response<ShareFileUploadInfo>> clearRangeWithResponse(long length, long offset, ShareRequestConditions requestConditions)
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.
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
file upload info
that only contains headers and response
status code.public Mono<Void> uploadFromFile(String uploadFilePath)
Code Samples
Upload the file from the source file path.
(@codesnippet com.azure.storage.file.share.ShareFileAsyncClient.uploadFromFile#string}For more information, see the Azure Docs Create File and Azure Docs Upload.
uploadFilePath
- The path where store the source file to uploadUncheckedIOException
- If an I/O error occurs.public Mono<Void> uploadFromFile(String uploadFilePath, ShareRequestConditions requestConditions)
Code Samples
Upload the file from the source file path.
(@codesnippet com.azure.storage.file.share.ShareFileAsyncClient.uploadFromFile#string-ShareRequestConditions}For more information, see the Azure Docs Create File and Azure Docs Upload.
uploadFilePath
- The path where store the source file to uploadrequestConditions
- ShareRequestConditions
UncheckedIOException
- If an I/O error occurs.public com.azure.core.http.rest.PagedFlux<ShareFileRange> listRanges()
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.
ranges
in the files.public com.azure.core.http.rest.PagedFlux<ShareFileRange> listRanges(ShareFileRange range)
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.
range
- Optional byte range which returns file data only from the specified range.ranges
in the files that satisfy the requirementspublic com.azure.core.http.rest.PagedFlux<ShareFileRange> listRanges(ShareFileRange range, ShareRequestConditions requestConditions)
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.
range
- Optional byte range which returns file data only from the specified range.requestConditions
- ShareRequestConditions
ranges
in the files that satisfy the requirementspublic Mono<ShareFileRangeList> listRangesDiff(String previousSnapshot)
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.
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.ranges
in the files that satisfy the requirementspublic Mono<com.azure.core.http.rest.Response<ShareFileRangeList>> listRangesDiffWithResponse(ShareFileListRangesDiffOptions options)
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.
options
- ShareFileListRangesDiffOptions
.ranges
in the files that satisfy the requirementspublic com.azure.core.http.rest.PagedFlux<HandleItem> listHandles()
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.
handles
in the files that satisfy the requirementspublic com.azure.core.http.rest.PagedFlux<HandleItem> listHandles(Integer maxResultsPerPage)
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.
maxResultsPerPage
- Optional maximum number of results will return per pagehandles
in the file that satisfy the requirementspublic Mono<CloseHandlesInfo> forceCloseHandle(String handleId)
ShareFileAsyncClient.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.
handleId
- Handle ID to be closed.public Mono<com.azure.core.http.rest.Response<CloseHandlesInfo>> forceCloseHandleWithResponse(String handleId)
ShareFileAsyncClient.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.
handleId
- Handle ID to be closed.public Mono<CloseHandlesInfo> forceCloseAllHandles()
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.
public String getShareSnapshotId()
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());
DateTime
value that identifies the share snapshot to its base
share.public String getShareName()
Get the share name.
String shareName = directoryAsyncClient.getShareName(); System.out.println("The share name of the directory is " + shareName);
public String getFilePath()
Get the file path.
String filePath = shareFileAsyncClient.getFilePath(); System.out.println("The name of the file is " + filePath);
public String getAccountName()
public com.azure.core.http.HttpPipeline getHttpPipeline()
HttpPipeline
powering this client.public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)
ShareServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential
See ShareServiceSasSignatureValues
for more information on how to construct a service SAS.
Code Samples
OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1); ShareFileSasPermission permission = new ShareFileSasPermission().setReadPermission(true); ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); shareFileAsyncClient.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
shareServiceSasSignatureValues
- ShareServiceSasSignatureValues
String
representing all SAS query parameters.Copyright © 2020 Microsoft Corporation. All rights reserved.