ShareFileAsyncClient Class
- java.
lang. Object - com.
azure. storage. file. share. ShareFileAsyncClient
- com.
public class ShareFileAsyncClient
This class provides a client that contains all the operations for interacting with file in Azure Storage File Service. Operations allowed by the client are creating, copying, uploading, downloading, deleting and listing on a file, retrieving properties, setting metadata and list or force close handles of the file.
Instantiating an Asynchronous File Client
ShareFileAsyncClient client = new ShareFileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileAsyncClient();
View ShareFileClientBuilder for additional ways to construct the client.
Method Summary
Methods inherited from java.lang.Object
Method Details
abortCopy
public Mono
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:
Returns:
abortCopyWithResponse
public Mono
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:
Returns:
abortCopyWithResponse
public Mono
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:
Returns:
beginCopy
public PollerFlux
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:
Returns:
beginCopy
public PollerFlux
Copies a blob or file to a destination file within the storage account.
Code Samples
Copy file from source url to the resourcePath
FileSmbProperties smbProperties = new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey");
String filePermission = "filePermission";
// NOTE: filePermission and filePermissionKey should never be both set
boolean ignoreReadOnly = false; // Default value
boolean setArchiveAttribute = true; // Default value
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
CopyableFileSmbPropertiesList list = new CopyableFileSmbPropertiesList().setCreatedOn(true).setLastWrittenOn(true);
// NOTE: FileSmbProperties and CopyableFileSmbPropertiesList should never be both set
ShareFileCopyOptions options = new ShareFileCopyOptions()
.setSmbProperties(smbProperties)
.setFilePermission(filePermission)
.setIgnoreReadOnly(ignoreReadOnly)
.setArchiveAttribute(setArchiveAttribute)
.setDestinationRequestConditions(requestConditions)
.setSmbPropertiesToCopy(list)
.setPermissionCopyModeType(PermissionCopyModeType.SOURCE)
.setMetadata(Collections.singletonMap("file", "metadata"))
.setFilePermissionFormat(FilePermissionFormat.BINARY);
PollerFlux<ShareFileCopyInfo, Void> poller = shareFileAsyncClient.beginCopy(
"https://{accountName}.file.core.windows.net?{SASToken}", options, Duration.ofSeconds(2));
poller.subscribe(response -> {
final ShareFileCopyInfo value = response.getValue();
System.out.printf("Copy source: %s. Status: %s.%n", value.getCopySourceUrl(), value.getCopyStatus());
}, error -> System.err.println("Error: " + error), () -> System.out.println("Complete copying the file."));
For more information, see the Azure Docs.
Parameters:
Returns:
beginCopy
public PollerFlux
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:
Returns:
clearRange
public Mono
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:
Returns:
clearRangeWithResponse
public Mono
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:
null
Returns:
clearRangeWithResponse
public Mono
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:
null
Returns:
create
public Mono
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:
Returns:
createWithResponse
public Mono
Creates a file in the storage account and returns a response of ShareFileInfo to interact with it.
Code Samples
Create the file with length of 1024 bytes, some headers, file smb properties and metadata.
ShareFileCreateOptions options = new ShareFileCreateOptions(1024);
options.setShareFileHttpHeaders(new ShareFileHttpHeaders()
.setContentType("text/html")
.setContentEncoding("gzip")
.setContentLanguage("en")
.setCacheControl("no-transform")
.setContentDisposition("attachment"));
options.setSmbProperties(new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey"));
options.setFilePermission("filePermission");
options.setFilePermissionFormat(FilePermissionFormat.BINARY);
options.setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId));
options.setMetadata(Collections.singletonMap("directory", "metadata"));
shareFileAsyncClient.createWithResponse(options)
.subscribe(response -> System.out.printf("Creating the file completed with status code %d",
response.getStatusCode()));
For more information, see the Azure Docs.
Parameters:
Returns:
createWithResponse
public Mono
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:
Returns:
createWithResponse
public Mono
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:
Returns:
delete
public Mono
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:
deleteIfExists
public Mono
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:
true
indicates that the file was successfully
deleted, false
indicates that the file did not exist.deleteIfExistsWithResponse
public Mono
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:
Returns:
deleteWithResponse
public Mono
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:
deleteWithResponse
public Mono
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:
Returns:
download
public Flux
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:
downloadToFile
public Mono
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:
Returns:
downloadToFileWithResponse
public Mono
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:
Returns:
downloadToFileWithResponse
public Mono
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:
Returns:
downloadWithResponse
public Mono
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:
Returns:
downloadWithResponse
public Mono
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:
Returns:
downloadWithResponse
public Mono
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:
Returns:
exists
public Mono
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:
existsWithResponse
public Mono
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:
forceCloseAllHandles
public Mono
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:
forceCloseHandle
public Mono
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:
Returns:
forceCloseHandleWithResponse
public Mono
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:
Returns:
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:
Returns:
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:
Returns:
String
representing the SAS query parameters.generateSas
public String generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues, Consumer
Generates a service SAS for the file using the specified ShareServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential
See ShareServiceSasSignatureValues for more information on how to construct a service SAS.
Parameters:
Returns:
String
representing the SAS query parameters.getAccountName
public String getAccountName()
Get associated account name.
Returns:
getAccountUrl
public String getAccountUrl()
Get the url of the storage account.
Returns:
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:
getFileUrl
public String getFileUrl()
Get the url of the storage file client.
Returns:
getHttpPipeline
public HttpPipeline getHttpPipeline()
Gets the HttpPipeline powering this client.
Returns:
getProperties
public Mono
Retrieves the properties of the storage account's file. The properties include file metadata, last modified date, is server encrypted, and eTag.
Code Samples
Retrieve file properties
shareFileAsyncClient.getProperties()
.subscribe(properties -> {
System.out.printf("File latest modified date is %s.", properties.getLastModified());
});
For more information, see the Azure Docs.
Returns:
getPropertiesWithResponse
public Mono
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:
getPropertiesWithResponse
public Mono
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:
Returns:
getServiceVersion
public ShareServiceVersion getServiceVersion()
Gets the service version the client is using.
Returns:
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:
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:
DateTime
value that identifies the share snapshot to its base
share.listHandles
public PagedFlux
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:
listHandles
public PagedFlux
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:
Returns:
listRanges
public PagedFlux
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:
listRanges
public PagedFlux
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:
Returns:
listRanges
public PagedFlux
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:
Returns:
listRangesDiff
public Mono
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:
Returns:
listRangesDiffWithResponse
public Mono
List of valid ranges for a file.
Code Samples
List all ranges within the file range from 1KB to 2KB.
shareFileAsyncClient.listRangesDiffWithResponse(new ShareFileListRangesDiffOptions("previoussnapshot")
.setRange(new ShareFileRange(1024, 2048L))).subscribe(response -> {
System.out.println("Valid Share File Ranges are:");
for (FileRange range : response.getValue().getRanges()) {
System.out.printf("Start: %s, End: %s%n", range.getStart(), range.getEnd());
}
});
For more information, see the Azure Docs.
Parameters:
Returns:
rename
public Mono
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:
Returns:
renameWithResponse
public Mono
Moves the file to another location within the share. For more information see the Azure Docs.
Code Samples
FileSmbProperties smbProperties = new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey");
ShareFileRenameOptions options = new ShareFileRenameOptions(destinationPath)
.setDestinationRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))
.setSourceRequestConditions(new ShareRequestConditions().setLeaseId(leaseId))
.setIgnoreReadOnly(false)
.setReplaceIfExists(false)
.setFilePermission("filePermission")
.setSmbProperties(smbProperties);
ShareFileAsyncClient newRenamedClient = client.renameWithResponse(options).block().getValue();
System.out.println("File Client has been renamed");
Parameters:
Returns:
setMetadata
public Mono
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:
Returns:
setMetadataWithResponse
public Mono
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:
Returns:
setMetadataWithResponse
public Mono
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:
Returns:
setProperties
public Mono
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:
Returns:
setPropertiesWithResponse
public Mono
Sets the user-defined file properties to associate to the file.
If null
is passed for the httpHeaders it will clear the httpHeaders associated to the file. If null
is passed for the filesmbproperties it will preserve the filesmbproperties associated with the file.
Code Samples
Set the httpHeaders of contentType of "text/plain"
ShareFileSetPropertiesOptions options = new ShareFileSetPropertiesOptions(1024);
options.setHttpHeaders(new ShareFileHttpHeaders()
.setContentType("text/html")
.setContentEncoding("gzip")
.setContentLanguage("en")
.setCacheControl("no-transform")
.setContentDisposition("attachment"));
options.setSmbProperties(new FileSmbProperties()
.setNtfsFileAttributes(EnumSet.of(NtfsFileAttributes.READ_ONLY))
.setFileCreationTime(OffsetDateTime.now())
.setFileLastWriteTime(OffsetDateTime.now())
.setFilePermissionKey("filePermissionKey"));
options.setFilePermissions(new ShareFilePermission().setPermission("filePermission")
.setPermissionFormat(FilePermissionFormat.BINARY));
options.setRequestConditions(new ShareRequestConditions().setLeaseId(leaseId));
// NOTE: filePermission and filePermissionKey should never be both set
shareFileAsyncClient.setPropertiesWithResponse(options)
.subscribe(response -> System.out.printf("Setting the file properties completed with status code %d",
response.getStatusCode()));
For more information, see the Azure Docs.
Parameters:
Returns:
setPropertiesWithResponse
public Mono
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:
Returns:
setPropertiesWithResponse
public Mono
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:
Returns:
upload
public Mono
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:
Returns:
upload
@Deprecated
public Mono
Deprecated
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:
Returns:
uploadFromFile
public Mono
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:
Returns:
uploadFromFile
public Mono
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:
Returns:
uploadRange
public Mono
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:
Returns:
uploadRangeFromUrl
public Mono
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:
Returns:
uploadRangeFromUrlWithResponse
public Mono
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:
Returns:
uploadRangeFromUrlWithResponse
public Mono
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:
Returns:
uploadRangeFromUrlWithResponse
public Mono
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:
Returns:
uploadRangeWithResponse
public Mono
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:
Returns:
uploadWithResponse
public Mono
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:
Returns:
uploadWithResponse
@Deprecated
public Mono
Deprecated
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:
null
.
Returns:
uploadWithResponse
@Deprecated
public Mono
Deprecated
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:
null
.
Returns:
Applies to
Azure SDK for Java