public class ShareClient extends Object
Instantiating a Synchronous Share Client
ShareClient client = new ShareClientBuilder() .connectionString("${connectionString}") .endpoint("${endpoint}") .buildClient();
View this
for additional ways to construct the client.
Modifier and Type | Method and Description |
---|---|
ShareInfo |
create()
Creates the share in the storage account.
|
ShareDirectoryClient |
createDirectory(String directoryName)
Creates the directory in the share with the given name.
|
com.azure.core.http.rest.Response<ShareDirectoryClient> |
createDirectoryWithResponse(String directoryName,
FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata,
Duration timeout,
com.azure.core.util.Context context)
Creates the directory in the share with the given name and associates the passed metadata to it.
|
ShareFileClient |
createFile(String fileName,
long maxSize)
Creates the file in the share with the given name and file max size.
|
com.azure.core.http.rest.Response<ShareFileClient> |
createFileWithResponse(String fileName,
long maxSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata,
Duration timeout,
com.azure.core.util.Context context)
Creates the file in the share with the given name, file max size and associates the passed properties to it.
|
com.azure.core.http.rest.Response<ShareFileClient> |
createFileWithResponse(String fileName,
long maxSize,
ShareFileHttpHeaders httpHeaders,
FileSmbProperties smbProperties,
String filePermission,
Map<String,String> metadata,
ShareRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Creates the file in the share with the given name, file max size and associates the passed properties to it.
|
String |
createPermission(String filePermission)
Creates a permission at the share level.
|
com.azure.core.http.rest.Response<String> |
createPermissionWithResponse(String filePermission,
com.azure.core.util.Context context)
Creates a permission t the share level.
|
ShareSnapshotInfo |
createSnapshot()
Creates a snapshot of the share with the same metadata associated to the share at the time of creation.
|
com.azure.core.http.rest.Response<ShareSnapshotInfo> |
createSnapshotWithResponse(Map<String,String> metadata,
Duration timeout,
com.azure.core.util.Context context)
Creates a snapshot of the share with the metadata that was passed associated to the snapshot.
|
com.azure.core.http.rest.Response<ShareInfo> |
createWithResponse(Map<String,String> metadata,
Integer quotaInGB,
Duration timeout,
com.azure.core.util.Context context)
Creates the share in the storage account with the specified metadata and quota.
|
void |
delete()
Deletes the share in the storage account
|
void |
deleteDirectory(String directoryName)
Deletes the specified directory in the share.
|
com.azure.core.http.rest.Response<Void> |
deleteDirectoryWithResponse(String directoryName,
Duration timeout,
com.azure.core.util.Context context)
Deletes the specified directory in the share.
|
void |
deleteFile(String fileName)
Deletes the specified file in the share.
|
com.azure.core.http.rest.Response<Void> |
deleteFileWithResponse(String fileName,
Duration timeout,
com.azure.core.util.Context context)
Deletes the specified file in the share.
|
com.azure.core.http.rest.Response<Void> |
deleteFileWithResponse(String fileName,
ShareRequestConditions requestConditions,
Duration timeout,
com.azure.core.util.Context context)
Deletes the specified file in the share.
|
com.azure.core.http.rest.Response<Void> |
deleteWithResponse(Duration timeout,
com.azure.core.util.Context context)
Deletes the share in the storage account
|
Boolean |
exists()
Determines if the share this client represents exists in the cloud.
|
com.azure.core.http.rest.Response<Boolean> |
existsWithResponse(Duration timeout,
com.azure.core.util.Context context)
Determines if the share this client represents exists in the cloud.
|
String |
generateSas(ShareServiceSasSignatureValues shareServiceSasSignatureValues)
Generates a service sas for the queue using the specified
ShareServiceSasSignatureValues
Note : The client must be authenticated via StorageSharedKeyCredential |
com.azure.core.http.rest.PagedIterable<ShareSignedIdentifier> |
getAccessPolicy()
Retrieves stored access policies specified for the share.
|
String |
getAccountName()
Get associated account name.
|
ShareDirectoryClient |
getDirectoryClient(String directoryName)
Constructs a
ShareDirectoryClient that interacts with the specified directory. |
ShareFileClient |
getFileClient(String filePath)
Constructs a
ShareFileClient that interacts with the specified file. |
com.azure.core.http.HttpPipeline |
getHttpPipeline()
Gets the
HttpPipeline powering this client. |
String |
getPermission(String filePermissionKey)
Gets a permission for a given key
|
com.azure.core.http.rest.Response<String> |
getPermissionWithResponse(String filePermissionKey,
com.azure.core.util.Context context)
Gets a permission for a given key.
|
ShareProperties |
getProperties()
Retrieves the properties of the share, these include the metadata associated to it and the quota that the share
is restricted to.
|
com.azure.core.http.rest.Response<ShareProperties> |
getPropertiesWithResponse(Duration timeout,
com.azure.core.util.Context context)
Retrieves the properties of the share, these include the metadata associated to it and the quota that the share
is restricted to.
|
ShareDirectoryClient |
getRootDirectoryClient()
Constructs a
ShareDirectoryClient that interacts with the root directory in the share. |
ShareServiceVersion |
getServiceVersion()
Gets the service version the client is using.
|
String |
getShareName()
Get share name from share client.
|
String |
getShareUrl()
Get the url of the storage share client.
|
String |
getSnapshotId()
Get snapshot id which attached to
ShareClient . |
ShareStatistics |
getStatistics()
Retrieves storage statistics about the share.
|
com.azure.core.http.rest.Response<ShareStatistics> |
getStatisticsWithResponse(Duration timeout,
com.azure.core.util.Context context)
Retrieves storage statistics about the share.
|
ShareInfo |
setAccessPolicy(List<ShareSignedIdentifier> permissions)
Sets stored access policies for the share.
|
com.azure.core.http.rest.Response<ShareInfo> |
setAccessPolicyWithResponse(List<ShareSignedIdentifier> permissions,
Duration timeout,
com.azure.core.util.Context context)
Sets stored access policies for the share.
|
ShareInfo |
setMetadata(Map<String,String> metadata)
Sets the user-defined metadata to associate to the share.
|
com.azure.core.http.rest.Response<ShareInfo> |
setMetadataWithResponse(Map<String,String> metadata,
Duration timeout,
com.azure.core.util.Context context)
Sets the user-defined metadata to associate to the share.
|
ShareInfo |
setQuota(int quotaInGB)
Sets the maximum size in GB that the share is allowed to grow.
|
com.azure.core.http.rest.Response<ShareInfo> |
setQuotaWithResponse(int quotaInGB,
Duration timeout,
com.azure.core.util.Context context)
Sets the maximum size in GB that the share is allowed to grow.
|
public String getShareUrl()
public ShareServiceVersion getServiceVersion()
public ShareDirectoryClient getRootDirectoryClient()
ShareDirectoryClient
that interacts with the root directory in the share.
If the directory doesn't exist in the share create
in the client will
need to be called before interaction with the directory can happen.
ShareDirectoryClient
that interacts with the root directory in the sharepublic ShareDirectoryClient getDirectoryClient(String directoryName)
ShareDirectoryClient
that interacts with the specified directory.
If the directory doesn't exist in the share create
in the client will
need to be called before interaction with the directory can happen.
directoryName
- Name of the directoryShareDirectoryClient
that interacts with the directory in the sharepublic ShareFileClient getFileClient(String filePath)
ShareFileClient
that interacts with the specified file.
If the file doesn't exist in the share ShareFileClient.create(long)
) create} in the client will
need to be called before interaction with the file can happen.
filePath
- Name of the fileShareFileClient
that interacts with the file in the sharepublic Boolean exists()
Code Samples
System.out.printf("Exists? %b%n", client.exists());
public com.azure.core.http.rest.Response<Boolean> existsWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
Context context = new Context("Key", "Value"); System.out.printf("Exists? %b%n", client.existsWithResponse(timeout, context).getValue());
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.context
- Additional context that is passed through the Http pipeline during the service call.public ShareInfo create()
Code Samples
Create the share
ShareInfo response = shareClient.create(); System.out.println("Complete creating the shares with status code: " + response);
For more information, see the Azure Docs.
information about the share
.ShareStorageException
- If the share already exists with different metadatapublic com.azure.core.http.rest.Response<ShareInfo> createWithResponse(Map<String,String> metadata, Integer quotaInGB, Duration timeout, com.azure.core.util.Context context)
Code Samples
Create the share with metadata "share:metadata"
Response<ShareInfo> response = shareClient.createWithResponse(Collections.singletonMap("share", "metadata"), null, Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete creating the shares with status code: " + response.getStatusCode());
Create the share with a quota of 10 GB
Response<ShareInfo> response = shareClient.createWithResponse(null, 10, Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete creating the shares with status code: " + response.getStatusCode());
For more information, see the Azure Docs.
metadata
- Optional metadata to associate with the sharequotaInGB
- Optional maximum size the share is allowed to grow to in GB. This must be greater than 0 and
less than or equal to 5120. The default value is 5120.timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.information about the share
and the status its creation.ShareStorageException
- If the share already exists with different metadata or quotaInGB
is outside
the allowed range.RuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareSnapshotInfo createSnapshot()
Code Samples
Create a snapshot
ShareSnapshotInfo response = shareClient.createSnapshot(); System.out.println("Complete creating the share snpashot with snapshot id: " + response.getSnapshot());
For more information, see the Azure Docs.
information about snapshot of share
ShareStorageException
- If the share doesn't exist, there are 200 snapshots of the share, or a snapshot is
in progress for the sharepublic com.azure.core.http.rest.Response<ShareSnapshotInfo> createSnapshotWithResponse(Map<String,String> metadata, Duration timeout, com.azure.core.util.Context context)
Code Samples
Create a snapshot with metadata "snapshot:metadata"
Response<ShareSnapshotInfo> response = shareClient.createSnapshotWithResponse(Collections.singletonMap("snpashot", "metadata"), Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete creating the share snpashot with snapshot id: " + response.getValue().getSnapshot());
For more information, see the Azure Docs.
metadata
- Optional metadata to associate with the snapshot. If null
the metadata of the share will
be copied to the snapshot.timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.information about snapshot of the share
and status of
creation.ShareStorageException
- If the share doesn't exist, there are 200 snapshots of the share, or a snapshot is
in progress for the shareRuntimeException
- if the operation doesn't complete before the timeout concludes.public void delete()
Code Samples
Delete the share
shareClient.delete(); System.out.println("Completed deleting the share.");
For more information, see the Azure Docs.
ShareStorageException
- If the share doesn't existpublic com.azure.core.http.rest.Response<Void> deleteWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
Delete the share
Response<Void> response = shareClient.deleteWithResponse(Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete deleting the share with status code: " + response.getStatusCode());
For more information, see the Azure Docs.
timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareStorageException
- If the share doesn't existRuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareProperties getProperties()
Code Samples
Retrieve the share properties
ShareProperties properties = shareClient.getProperties(); System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());
For more information, see the Azure Docs.
properties of the share
ShareStorageException
- If the share doesn't existpublic com.azure.core.http.rest.Response<ShareProperties> getPropertiesWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
Retrieve the share properties
ShareProperties properties = shareClient.getPropertiesWithResponse( Duration.ofSeconds(1), new Context(key1, value1)).getValue(); System.out.printf("Share quota: %d, Metadata: %s", properties.getQuota(), properties.getMetadata());
For more information, see the Azure Docs.
timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.properties of the share
with response status codeShareStorageException
- If the share doesn't existRuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareInfo setQuota(int quotaInGB)
Code Samples
Set the quota to 1024 GB
System.out.println("Setting the share quota completed." + shareClient.setQuota(1024));
For more information, see the Azure Docs.
quotaInGB
- Size in GB to limit the share's growth. The quota in GB must be between 1 and 5120.properties of the share
ShareStorageException
- If the share doesn't exist or quotaInGB
is outside the allowed boundspublic com.azure.core.http.rest.Response<ShareInfo> setQuotaWithResponse(int quotaInGB, Duration timeout, com.azure.core.util.Context context)
Code Samples
Set the quota to 1024 GB
Response<ShareInfo> response = shareClient.setQuotaWithResponse(1024, Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Setting the share quota completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
quotaInGB
- Size in GB to limit the share's growth. The quota in GB must be between 1 and 5120.timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.properties of the share
with response status codeShareStorageException
- If the share doesn't exist or quotaInGB
is outside the allowed boundsRuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareInfo setMetadata(Map<String,String> metadata)
If null
is passed for the metadata it will clear the metadata associated to the share.
Code Samples
Set the metadata to "share:updatedMetadata"
shareClient.setMetadata(Collections.singletonMap("share", "updatedMetadata")); System.out.println("Setting the share metadata.");
Clear the metadata of the share
shareClient.setMetadata(null); System.out.println("Clear metadata completed.");
For more information, see the Azure Docs.
metadata
- Metadata to set on the share, if null is passed the metadata for the share is clearedproperties of the share
ShareStorageException
- If the share doesn't exist or the metadata contains invalid keyspublic com.azure.core.http.rest.Response<ShareInfo> setMetadataWithResponse(Map<String,String> metadata, Duration timeout, com.azure.core.util.Context context)
If null
is passed for the metadata it will clear the metadata associated to the share.
Code Samples
Set the metadata to "share:updatedMetadata"
Response<ShareInfo> response = shareClient.setMetadataWithResponse( Collections.singletonMap("share", "updatedMetadata"), Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Setting the share metadata completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
metadata
- Metadata to set on the share, if null is passed the metadata for the share is clearedtimeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.properties of the share
with response status codeShareStorageException
- If the share doesn't exist or the metadata contains invalid keysRuntimeException
- if the operation doesn't complete before the timeout concludes.public com.azure.core.http.rest.PagedIterable<ShareSignedIdentifier> getAccessPolicy()
Code Samples
List the stored access policies
for (ShareSignedIdentifier result : shareClient.getAccessPolicy()) { System.out.printf("Access policy %s allows these permissions: %s", result.getId(), result.getAccessPolicy().getPermissions()); }
For more information, see the Azure Docs.
ShareStorageException
- If the share doesn't existpublic ShareInfo setAccessPolicy(List<ShareSignedIdentifier> permissions)
Code Samples
Set a read only stored access policy
ShareAccessPolicy accessPolicy = new ShareAccessPolicy().setPermissions("r") .setStartsOn(OffsetDateTime.now(ZoneOffset.UTC)) .setExpiresOn(OffsetDateTime.now(ZoneOffset.UTC).plusDays(10)); ShareSignedIdentifier permission = new ShareSignedIdentifier().setId("mypolicy").setAccessPolicy(accessPolicy); shareClient.setAccessPolicy(Collections.singletonList(permission)); System.out.println("Setting access policies completed.");
For more information, see the Azure Docs.
permissions
- Access policies to set on the queueinformation of the share
ShareStorageException
- If the share doesn't exist, a stored access policy doesn't have all fields filled
out, or the share will have more than five policies.public com.azure.core.http.rest.Response<ShareInfo> setAccessPolicyWithResponse(List<ShareSignedIdentifier> permissions, Duration timeout, com.azure.core.util.Context context)
Code Samples
Set a read only stored access policy
ShareAccessPolicy accessPolicy = new ShareAccessPolicy().setPermissions("r") .setStartsOn(OffsetDateTime.now(ZoneOffset.UTC)) .setExpiresOn(OffsetDateTime.now(ZoneOffset.UTC).plusDays(10)); ShareSignedIdentifier permission = new ShareSignedIdentifier().setId("mypolicy").setAccessPolicy(accessPolicy); Response<ShareInfo> response = shareClient.setAccessPolicyWithResponse(Collections.singletonList(permission), Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Setting access policies completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
permissions
- Access policies to set on the queuetimeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.information of the share
with headers and response status
codeShareStorageException
- If the share doesn't exist, a stored access policy doesn't have all fields filled
out, or the share will have more than five policies.RuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareStatistics getStatistics()
Code Samples
Retrieve the storage statistics
ShareStatistics response = shareClient.getStatistics(); System.out.printf("The share is using %d GB", response.getShareUsageInGB());
For more information, see the Azure Docs.
statistics of the share
public com.azure.core.http.rest.Response<ShareStatistics> getStatisticsWithResponse(Duration timeout, com.azure.core.util.Context context)
Code Samples
Retrieve the storage statistics
Response<ShareStatistics> response = shareClient.getStatisticsWithResponse( Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("The share is using %d GB", response.getValue().getShareUsageInGB());
For more information, see the Azure Docs.
timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.statistics of the share
RuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareDirectoryClient createDirectory(String directoryName)
Code Samples
Create the directory "documents"
ShareDirectoryClient response = shareClient.createDirectory("mydirectory"); System.out.println("Complete creating the directory.");
For more information, see the Azure Docs.
directoryName
- Name of the directoryShareDirectoryClient
to interact with the created directory.ShareStorageException
- If the share doesn't exist, the directory already exists or is in the process of
being deleted, or the parent directory for the new directory doesn't existpublic com.azure.core.http.rest.Response<ShareDirectoryClient> createDirectoryWithResponse(String directoryName, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, Duration timeout, com.azure.core.util.Context context)
Code Samples
Create the directory "documents" with metadata "directory:metadata"
FileSmbProperties smbProperties = new FileSmbProperties(); String filePermission = "filePermission"; Response<ShareDirectoryClient> response = shareClient.createDirectoryWithResponse("documents", smbProperties, filePermission, Collections.singletonMap("directory", "metadata"), Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Creating the directory completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
directoryName
- Name of the directorysmbProperties
- The SMB properties of the directory.filePermission
- The file permission of the directory.metadata
- Optional metadata to associate with the directorycontext
- Additional context that is passed through the Http pipeline during the service call.timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.ShareDirectoryAsyncClient
to interact with the created directory and the
status of its creation.ShareStorageException
- If the share doesn't exist, the directory already exists or is in the process of
being deleted, the parent directory for the new directory doesn't exist, or the metadata is using an illegal key
nameRuntimeException
- if the operation doesn't complete before the timeout concludes.public ShareFileClient createFile(String fileName, long maxSize)
Code Samples
Create the file "myfile" with size of 1024 bytes.
ShareFileClient response = shareClient.createFile("myfile", 1024); System.out.println("Complete creating the file with snapshot Id:" + response.getShareSnapshotId());
For more information, see the Azure Docs.
fileName
- Name of the file.maxSize
- The maximum size in bytes for the file.ShareFileClient
to interact with the created file.ShareStorageException
- If one of the following cases happen:
public com.azure.core.http.rest.Response<ShareFileClient> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, Duration timeout, com.azure.core.util.Context context)
Code Samples
Create the file "myfile" 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 Response<ShareFileClient> response = shareClient.createFileWithResponse("myfile", 1024, httpHeaders, smbProperties, filePermission, Collections.singletonMap("directory", "metadata"), Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Creating the file completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
fileName
- Name of the file.maxSize
- The maximum size in bytes for the file.httpHeaders
- Additional parameters for the operation.smbProperties
- The user settable file smb properties.filePermission
- The file permission of the filemetadata
- Optional name-value pairs associated with the file as metadata.timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareFileClient
to interact with the created file and the status of its
creation.ShareStorageException
- If one of the following cases happen:
RuntimeException
- if the operation doesn't complete before the timeout concludes.public com.azure.core.http.rest.Response<ShareFileClient> createFileWithResponse(String fileName, long maxSize, ShareFileHttpHeaders httpHeaders, FileSmbProperties smbProperties, String filePermission, Map<String,String> metadata, ShareRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
Create the file "myfile" 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); Response<ShareFileClient> response = shareClient.createFileWithResponse("myfile", 1024, httpHeaders, smbProperties, filePermission, Collections.singletonMap("directory", "metadata"), requestConditions, Duration.ofSeconds(1), new Context(key1, value1)); System.out.printf("Creating the file completed with status code %d", response.getStatusCode());
For more information, see the Azure Docs.
fileName
- Name of the file.maxSize
- The maximum size in bytes for the file.httpHeaders
- Additional parameters for the operation.smbProperties
- The user settable file smb properties.filePermission
- The file permission of the filemetadata
- Optional name-value pairs associated with the file as metadata.requestConditions
- ShareRequestConditions
timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareFileClient
to interact with the created file and the status of its
creation.ShareStorageException
- If one of the following cases happen:
RuntimeException
- if the operation doesn't complete before the timeout concludes.public void deleteDirectory(String directoryName)
Code Samples
Delete the directory "mydirectory"
shareClient.deleteDirectory("mydirectory"); System.out.println("Completed deleting the directory.");
For more information, see the Azure Docs.
directoryName
- Name of the directoryShareStorageException
- If the share doesn't exist or the directory isn't emptypublic com.azure.core.http.rest.Response<Void> deleteDirectoryWithResponse(String directoryName, Duration timeout, com.azure.core.util.Context context)
Code Samples
Delete the directory "mydirectory"
Response<Void> response = shareClient.deleteDirectoryWithResponse("mydirectory", Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete deleting the directory with status code: " + response.getStatusCode());
For more information, see the Azure Docs.
directoryName
- Name of the directorytimeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareStorageException
- If the share doesn't exist or the directory isn't emptyRuntimeException
- if the operation doesn't complete before the timeout concludes.public void deleteFile(String fileName)
Code Samples
Delete the file "myfile"
shareClient.deleteFile("myfile"); System.out.println("Complete deleting the file.");
For more information, see the Azure Docs.
fileName
- Name of the fileShareStorageException
- If the share or the file doesn't exist.public com.azure.core.http.rest.Response<Void> deleteFileWithResponse(String fileName, Duration timeout, com.azure.core.util.Context context)
Code Samples
Delete the file "myfile"
Response<Void> response = shareClient.deleteFileWithResponse("myfile", Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete deleting the file with status code: " + response.getStatusCode());
For more information, see the Azure Docs.
fileName
- Name of the filetimeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareStorageException
- If the share or the file doesn't exist.RuntimeException
- if the operation doesn't complete before the timeout concludes.public com.azure.core.http.rest.Response<Void> deleteFileWithResponse(String fileName, ShareRequestConditions requestConditions, Duration timeout, com.azure.core.util.Context context)
Code Samples
Delete the file "myfile"
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId); Response<Void> response = shareClient.deleteFileWithResponse("myfile", requestConditions, Duration.ofSeconds(1), new Context(key1, value1)); System.out.println("Complete deleting the file with status code: " + response.getStatusCode());
For more information, see the Azure Docs.
fileName
- Name of the filerequestConditions
- ShareRequestConditions
timeout
- An optional timeout applied to the operation. If a response is not returned before the timeout
concludes a RuntimeException
will be thrown.context
- Additional context that is passed through the Http pipeline during the service call.ShareStorageException
- If the share or the file doesn't exist.RuntimeException
- if the operation doesn't complete before the timeout concludes.public String createPermission(String filePermission)
Code Samples
String response = shareClient.createPermission("filePermission"); System.out.printf("The file permission key is %s", response);
filePermission
- The file permission to get/create.public com.azure.core.http.rest.Response<String> createPermissionWithResponse(String filePermission, com.azure.core.util.Context context)
Code Samples
Response<String> response = shareClient.createPermissionWithResponse("filePermission", Context.NONE); System.out.printf("The file permission key is %s", response.getValue());
filePermission
- The file permission to get/create.context
- Additional context that is passed through the Http pipeline during the service call.public String getPermission(String filePermissionKey)
Code Samples
String response = shareClient.getPermission("filePermissionKey"); System.out.printf("The file permission is %s", response);
filePermissionKey
- The file permission key.public com.azure.core.http.rest.Response<String> getPermissionWithResponse(String filePermissionKey, com.azure.core.util.Context context)
Code Samples
Response<String> response = shareClient.getPermissionWithResponse("filePermissionKey", Context.NONE); System.out.printf("The file permission is %s", response.getValue());
filePermissionKey
- The file permission key.context
- Additional context that is passed through the Http pipeline during the service call.public String getSnapshotId()
ShareClient
. Return null
if no snapshot id attached.
Code Samples
Get the share snapshot id.
OffsetDateTime currentTime = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC); ShareClient shareClient = new ShareClientBuilder().endpoint("https://${accountName}.file.core.windows.net") .sasToken("${SASToken}") .shareName("myshare") .snapshot(currentTime.toString()) .buildClient(); System.out.printf("Snapshot ID: %s%n", shareClient.getSnapshotId());
DateTime
value that identifies the share snapshot to its base
share.public String getShareName()
Code Samples
String shareName = shareAsyncClient.getShareName(); System.out.println("The name of the share is " + shareName);
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); ShareSasPermission permission = new ShareSasPermission().setReadPermission(true); ShareServiceSasSignatureValues values = new ShareServiceSasSignatureValues(expiryTime, permission) .setStartTime(OffsetDateTime.now()); shareAsyncClient.generateSas(values); // Client must be authenticated via StorageSharedKeyCredential
shareServiceSasSignatureValues
- ShareServiceSasSignatureValues
String
representing all SAS query parameters.Copyright © 2020 Microsoft Corporation. All rights reserved.