public final class CloudFile extends Object implements ListFileItem
Constructor and Description |
---|
CloudFile(CloudFile otherFile)
Creates an instance of the
CloudFile class by copying values from another cloud file. |
CloudFile(StorageUri fileAbsoluteUri)
Creates an instance of the
CloudFile class using the specified absolute StorageUri. |
CloudFile(StorageUri fileAbsoluteUri,
StorageCredentials credentials)
Creates an instance of the
CloudFile class using the specified absolute StorageUri
and credentials. |
CloudFile(URI fileAbsoluteUri)
Creates an instance of the
CloudFile class using the specified absolute URI. |
CloudFile(URI fileAbsoluteUri,
StorageCredentials credentials)
Creates an instance of the
CloudFile class using the specified absolute URI
and credentials. |
Modifier and Type | Method and Description |
---|---|
void |
abortCopy(String copyId)
Aborts an ongoing Azure File copy operation.
|
void |
abortCopy(String copyId,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Aborts an ongoing Azure File copy operation.
|
void |
clearRange(long offset,
long length)
Clears a range from a file.
|
void |
clearRange(long offset,
long length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Clears a range from a file using the specified lease ID, request options, and operation context.
|
void |
create(long size)
Creates a file.
|
void |
create(long size,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Creates a file using the specified access condition, request options and operation context.
|
void |
delete()
Deletes the file.
|
void |
delete(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Deletes the file using the specified access condition, request options, and operation context.
|
boolean |
deleteIfExists()
Deletes the file if it exists.
|
boolean |
deleteIfExists(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Deletes the file if it exists, using the specified access condition, request options, and operation context.
|
void |
download(OutputStream outStream)
Downloads the contents of a file to a stream.
|
void |
download(OutputStream outStream,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads the contents of a file to a stream using the specified request options and operation context.
|
void |
downloadAttributes()
Populates a file's properties and metadata.
|
void |
downloadAttributes(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Populates a file's properties and metadata using the specified request options and operation context.
|
ArrayList<FileRange> |
downloadFileRanges()
Returns a collection of file ranges and their starting and ending byte offsets.
|
ArrayList<FileRange> |
downloadFileRanges(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Returns a collection of file ranges and their starting and ending byte offsets using the specified request
options and operation context.
|
void |
downloadRange(long offset,
Long length,
OutputStream outStream)
Downloads the contents of a file to a stream.
|
void |
downloadRange(long offset,
Long length,
OutputStream outStream,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads the contents of a file to a stream using the specified request options and operation context.
|
int |
downloadRangeToByteArray(long offset,
Long length,
byte[] buffer,
int bufferOffset)
Downloads a range of bytes from the file to the given byte buffer.
|
int |
downloadRangeToByteArray(long offset,
Long length,
byte[] buffer,
int bufferOffset,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads a range of bytes from the file to the given byte buffer, using the specified request options and
operation context.
|
String |
downloadText()
Downloads a file to a string using the platform's default encoding.
|
String |
downloadText(String charsetName,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads a file to a string using the specified encoding.
|
int |
downloadToByteArray(byte[] buffer,
int bufferOffset)
Downloads a range of bytes from the file to the given byte buffer.
|
int |
downloadToByteArray(byte[] buffer,
int bufferOffset,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads a range of bytes from the file to the given byte buffer, using the specified request options and
operation context.
|
void |
downloadToFile(String path)
Downloads a file.
|
void |
downloadToFile(String path,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Downloads a file.
|
boolean |
exists()
Checks to see if the file exists.
|
boolean |
exists(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Checks to see if the file exists, using the specified access condition, request options and operation context.
|
String |
generateSharedAccessSignature(SharedAccessFilePolicy policy,
SharedAccessFileHeaders headers,
String groupPolicyIdentifier)
Returns a shared access signature for the file using the specified group policy identifier and
shared access file headers.
|
String |
generateSharedAccessSignature(SharedAccessFilePolicy policy,
SharedAccessFileHeaders headers,
String groupPolicyIdentifier,
IPRange ipRange,
SharedAccessProtocols protocols)
Returns a shared access signature for the file using the specified group policy identifier and
shared access file headers.
|
String |
generateSharedAccessSignature(SharedAccessFilePolicy policy,
String groupPolicyIdentifier)
Returns a shared access signature for the file using the specified group policy identifier and
shared access file headers.
|
CopyState |
getCopyState()
Returns the Azure File's copy state.
|
HashMap<String,String> |
getMetadata()
Returns the metadata for the file.
|
String |
getName()
Returns the name of the file.
|
CloudFileDirectory |
getParent()
Returns the file item's parent.
|
FileProperties |
getProperties()
Returns the file's properties.
|
CloudFileClient |
getServiceClient()
Returns the file service client associated with the file.
|
CloudFileShare |
getShare()
Returns the file's share.
|
StorageUri |
getStorageUri()
Returns the list of URIs for all locations.
|
int |
getStreamMinimumReadSizeInBytes()
Returns the minimum read size when using a
FileInputStream . |
int |
getStreamWriteSizeInBytes()
Gets the number of bytes to buffer when writing to a
FileOutputStream . |
URI |
getUri()
Returns the URI for this file.
|
FileInputStream |
openRead()
Opens a file input stream to download the file.
|
FileInputStream |
openRead(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Opens a file input stream to download the file using the specified request options and
operation context.
|
FileOutputStream |
openWriteExisting()
Opens an output stream object to write data to the file.
|
FileOutputStream |
openWriteExisting(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Opens an output stream object to write data to the file, using specified request options and
operation context.
|
FileOutputStream |
openWriteNew(long length)
Opens an output stream object to write data to the file.
|
FileOutputStream |
openWriteNew(long length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Opens an output stream object to write data to the file, using the specified lease ID, request options and
operation context.
|
void |
resize(long size)
Resizes the file to the specified size.
|
void |
resize(long size,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Resizes the file to the specified size.
|
void |
setMetadata(HashMap<String,String> metadata)
Sets the metadata for the file.
|
void |
setStreamMinimumReadSizeInBytes(int minimumReadSize)
Sets the minimum read size when using a
FileInputStream . |
void |
setStreamWriteSizeInBytes(int streamWriteSizeInBytes)
Sets the number of bytes to buffer when writing to a
FileOutputStream . |
String |
startCopy(CloudBlob sourceBlob)
Requests the service to start copying a blob's contents, properties, and metadata to a new file.
|
String |
startCopy(CloudBlob sourceBlob,
AccessCondition sourceAccessCondition,
AccessCondition destinationAccessCondition,
FileRequestOptions options,
OperationContext opContext)
Requests the service to start copying a file's contents, properties, and metadata to a new file,
using the specified access conditions, lease ID, request options, and operation context.
|
String |
startCopy(CloudFile sourceFile)
Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File.
|
String |
startCopy(CloudFile sourceFile,
AccessCondition sourceAccessCondition,
AccessCondition destinationAccessCondition,
FileRequestOptions options,
OperationContext opContext)
Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File,
using the specified access conditions, lease ID, request options, and operation context.
|
String |
startCopy(URI source)
Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File.
|
String |
startCopy(URI source,
AccessCondition sourceAccessCondition,
AccessCondition destinationAccessCondition,
FileRequestOptions options,
OperationContext opContext)
Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File,
using the specified access conditions, lease ID, request options, and operation context.
|
void |
upload(InputStream sourceStream,
long length)
Uploads the source stream data to the file.
|
void |
upload(InputStream sourceStream,
long length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads the source stream data to the file using the specified access condition, request options, and operation
context.
|
void |
uploadFromByteArray(byte[] buffer,
int offset,
int length)
Uploads a file from data in a byte array.
|
void |
uploadFromByteArray(byte[] buffer,
int offset,
int length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads a file from data in a byte array.
|
void |
uploadFromFile(String path)
Uploads a local file.
|
void |
uploadFromFile(String path,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads a file from a local file.
|
void |
uploadMetadata()
Uploads the file's metadata to the storage service.
|
void |
uploadMetadata(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads the file's metadata to the storage service using the access condition, request options, and operation
context.
|
void |
uploadProperties()
Updates the file's properties to the storage service.
|
void |
uploadProperties(AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Updates the file's properties using the access condition, request options, and operation context.
|
void |
uploadRange(InputStream sourceStream,
long offset,
long length)
Uploads a range to a file.
|
void |
uploadRange(InputStream sourceStream,
long offset,
long length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads a range to a file using the specified lease ID, request options, and operation context.
|
void |
uploadText(String content)
Uploads a file from a string using the platform's default encoding.
|
void |
uploadText(String content,
String charsetName,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads a file from a string using the specified encoding.
|
public CloudFile(URI fileAbsoluteUri) throws StorageException, URISyntaxException
CloudFile
class using the specified absolute URI.fileAbsoluteUri
- A java.net.URI
object that represents the absolute URI to the file.StorageException
- If a storage service error occurred.URISyntaxException
- If the resource URI is invalid.public CloudFile(StorageUri fileAbsoluteUri) throws StorageException, URISyntaxException
CloudFile
class using the specified absolute StorageUri.fileAbsoluteUri
- A StorageUri
object that represents the absolute URI to the file.StorageException
- If a storage service error occurred.URISyntaxException
- If the resource URI is invalid.public CloudFile(URI fileAbsoluteUri, StorageCredentials credentials) throws StorageException, URISyntaxException
CloudFile
class using the specified absolute URI
and credentials.fileAbsoluteUri
- A java.net.URI
object that represents the absolute URI to the file.credentials
- A StorageCredentials
object used to authenticate access.StorageException
- If a storage service error occurred.URISyntaxException
public CloudFile(StorageUri fileAbsoluteUri, StorageCredentials credentials) throws StorageException, URISyntaxException
CloudFile
class using the specified absolute StorageUri
and credentials.fileAbsoluteUri
- A StorageUri
object that represents the absolute URI to the file.credentials
- A StorageCredentials
object used to authenticate access.StorageException
- If a storage service error occurred.URISyntaxException
public CloudFile(CloudFile otherFile)
CloudFile
class by copying values from another cloud file.otherFile
- A CloudFile
object that represents the file to copy.@DoesServiceRequest public final void abortCopy(String copyId) throws StorageException, URISyntaxException
copyId
- A String
object that identifies the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void abortCopy(String copyId, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
copyId
- A String
object that identifies the copy operation.accessCondition
- An AccessCondition
object that represents the access conditions for the Azure File.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(CloudBlob sourceBlob) throws StorageException, URISyntaxException
sourceBlob
- A CloudBlob
object that represents the source blob to copy.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(CloudBlob sourceBlob, AccessCondition sourceAccessCondition, AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
sourceBlob
- A CloudBlob
object that represents the source blob to copy.sourceAccessCondition
- An AccessCondition
object that represents the access conditions for the source blob.destinationAccessCondition
- An AccessCondition
object that represents the access conditions for the destination file.options
- A BlobRequestOptions
object that specifies any additional options for the request.
Specifying null
will use the default request options from the associated
service client (CloudBlobClient
).opContext
- An OperationContext
object that represents the context for the current operation.
This object is used to track requests to the storage service, and to provide additional
runtime information about the operation.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(CloudFile sourceFile) throws StorageException, URISyntaxException
sourceFile
- A CloudFile
object that represents the source Azure File to copy.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(CloudFile sourceFile, AccessCondition sourceAccessCondition, AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
sourceFile
- A CloudFile
object that represents the source file to copy.sourceAccessCondition
- An AccessCondition
object that represents the access conditions for the source.destinationAccessCondition
- An AccessCondition
object that represents the access conditions for the destination.options
- A FileRequestOptions
object that specifies any additional options for the request.
Specifying null
will use the default request options from the associated
service client (CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation.
This object is used to track requests to the storage service, and to provide additional
runtime information about the operation.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(URI source) throws StorageException, URISyntaxException
source
- The source's java.net.URI
.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final String startCopy(URI source, AccessCondition sourceAccessCondition, AccessCondition destinationAccessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
source
- The source's java.net.URI
.sourceAccessCondition
- An AccessCondition
object that represents the access conditions for the source.destinationAccessCondition
- An AccessCondition
object that represents the access conditions for the destination.options
- A FileRequestOptions
object that specifies any additional options for the request.
Specifying null
will use the default request options from the associated
service client (CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation.
This object is used to track requests to the storage service, and to provide additional
runtime information about the operation.String
which represents the copy ID associated with the copy operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void clearRange(long offset, long length) throws StorageException, URISyntaxException
Calling clearRange
releases the storage space used by the specified range. Ranges that have been
cleared are no longer tracked as part of the file.
offset
- The offset, in bytes, at which to begin clearing.length
- The length, in bytes, of the data range to be cleared.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void clearRange(long offset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
Calling clearRange
releases the storage space used by the specified range. Ranges that have been
cleared are no longer tracked as part of the file.
offset
- A long
which represents the offset, in bytes, at which to begin clearing.length
- A long
which represents the length, in bytes, of the data range to be cleared.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void create(long size) throws StorageException, URISyntaxException
size
- A long
which represents the size, in bytes, of the file.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void create(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
size
- A long
which represents the size, in bytes, of the file.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void delete() throws StorageException, URISyntaxException
StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void delete(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final boolean deleteIfExists() throws StorageException, URISyntaxException
true
if the file was deleted; otherwise, false
.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final boolean deleteIfExists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.true
if the file existed and was deleted; otherwise, false
StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void download(OutputStream outStream) throws StorageException
outStream
- An OutputStream
object that represents the target stream.StorageException
- If a storage service error occurred.@DoesServiceRequest public final void download(OutputStream outStream, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
outStream
- An OutputStream
object that represents the target stream.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.@DoesServiceRequest public final void downloadRange(long offset, Long length, OutputStream outStream) throws StorageException
offset
- A long
which represents the offset to use as the starting point for the source.length
- A Long
which represents the number of bytes to read or null
.outStream
- An OutputStream
object that represents the target stream.StorageException
- If a storage service error occurred.@DoesServiceRequest public final void downloadRange(long offset, Long length, OutputStream outStream, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
offset
- A long
which represents the offset to use as the starting point for the source.length
- A Long
which represents the number of bytes to read or null
.outStream
- An OutputStream
object that represents the target stream.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.@DoesServiceRequest public final int downloadRangeToByteArray(long offset, Long length, byte[] buffer, int bufferOffset) throws StorageException
offset
- A long
which represents the byte offset to use as the starting point for the source.length
- A Long
which represents the number of bytes to read or null.buffer
- A byte
array which represents the buffer to which the file bytes are downloaded.bufferOffset
- An int
which represents the byte offset to use as the starting point for the target.StorageException
@DoesServiceRequest public final int downloadRangeToByteArray(long offset, Long length, byte[] buffer, int bufferOffset, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
offset
- A long
which represents the byte offset to use as the starting point for the source.length
- A Long
which represents the number of bytes to read or null
.buffer
- A byte
array which represents the buffer to which the file bytes are downloaded.bufferOffset
- An int
which represents the byte offset to use as the starting point for the target.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.@DoesServiceRequest public final int downloadToByteArray(byte[] buffer, int bufferOffset) throws StorageException
buffer
- A byte
array which represents the buffer to which the file bytes are downloaded.bufferOffset
- An int
which represents the byte offset to use as the starting point for the target.StorageException
- If a storage service error occurred.@DoesServiceRequest public final int downloadToByteArray(byte[] buffer, int bufferOffset, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
buffer
- A byte
array which represents the buffer to which the file bytes are downloaded.bufferOffset
- A long
which represents the byte offset to use as the starting point for the target.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.public void downloadToFile(String path) throws StorageException, IOException
path
- A String
which represents the path to the file that will be created.StorageException
- If a storage service error occurred.IOException
public void downloadToFile(String path, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
path
- A String
which represents the path to the file that will be created.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.IOException
public String downloadText() throws StorageException, IOException
String
which represents the file's contents.StorageException
- If a storage service error occurred.IOException
public String downloadText(String charsetName, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
charsetName
- A String
which represents the name of the charset to use to encode the content.
If null, the platform's default encoding is used.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.String
which represents the file's contents.StorageException
- If a storage service error occurred.IOException
@DoesServiceRequest public ArrayList<FileRange> downloadFileRanges() throws StorageException
The start and end byte offsets for each file range are inclusive.
ArrayList
object which represents the set of file ranges and their starting and ending
byte offsets.StorageException
- If a storage service error occurred.@DoesServiceRequest public ArrayList<FileRange> downloadFileRanges(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.ArrayList
object which represents the set of file ranges and their starting
and ending byte offsets.StorageException
- If a storage service error occurred.@DoesServiceRequest public final void downloadAttributes() throws StorageException
This method populates the file's system properties and user-defined metadata. Before reading or modifying a file's properties or metadata, call this method or its overload to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.
StorageException
- If a storage service error occurred.@DoesServiceRequest public final void downloadAttributes(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
This method populates the file's system properties and user-defined metadata. Before reading or modifying a file's properties or metadata, call this method or its overload to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.@DoesServiceRequest public final boolean exists() throws StorageException
true
if the file exists, otherwise false
.StorageException
- If a storage service error occurred.@DoesServiceRequest public final boolean exists(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.true
if the file exists, otherwise false
.StorageException
- If a storage service error occurred.public String generateSharedAccessSignature(SharedAccessFilePolicy policy, String groupPolicyIdentifier) throws InvalidKeyException, StorageException
policy
- A SharedAccessFilePolicy
object that represents the access policy for the shared
access signature.groupPolicyIdentifier
- A String
that represents the share-level access policy.String
that represents the shared access signature.InvalidKeyException
- If the credentials are invalid.StorageException
- If a storage service error occurred.public String generateSharedAccessSignature(SharedAccessFilePolicy policy, SharedAccessFileHeaders headers, String groupPolicyIdentifier) throws InvalidKeyException, StorageException
policy
- A SharedAccessFilePolicy
object that represents the access policy for the shared
access signature.headers
- A SharedAccessFileHeaders
object that represents the optional header values to
set for a file accessed with this shared access signature.groupPolicyIdentifier
- A String
that represents the share-level access policy.String
that represents the shared access signature.IllegalArgumentException
- If the credentials are invalid.InvalidKeyException
- If the credentials are invalid.StorageException
- If a storage service error occurred.public String generateSharedAccessSignature(SharedAccessFilePolicy policy, SharedAccessFileHeaders headers, String groupPolicyIdentifier, IPRange ipRange, SharedAccessProtocols protocols) throws InvalidKeyException, StorageException
policy
- A SharedAccessFilePolicy
object that represents the access policy for the shared
access signature.headers
- A SharedAccessFileHeaders
object that represents the optional header values to
set for a file accessed with this shared access signature.groupPolicyIdentifier
- A String
that represents the share-level access policy.ipRange
- A IPRange
object containing the range of allowed IP addresses.protocols
- A SharedAccessProtocols
representing the allowed Internet protocols.String
that represents the shared access signature.IllegalArgumentException
- If the credentials are invalid.InvalidKeyException
- If the credentials are invalid.StorageException
- If a storage service error occurred.public CopyState getCopyState()
CopyState
object that represents the copy state of the file.@DoesServiceRequest public final FileInputStream openRead() throws StorageException
Use setStreamMinimumReadSizeInBytes(int)
to configure the read size.
InputStream
object that represents the stream to use for reading from the file.StorageException
- If a storage service error occurred.@DoesServiceRequest public final FileInputStream openRead(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
Use setStreamMinimumReadSizeInBytes(int)
to configure the read size.
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.InputStream
object that represents the stream to use for reading from the file.StorageException
- If a storage service error occurred.@DoesServiceRequest public FileOutputStream openWriteExisting() throws StorageException, URISyntaxException
FileOutputStream
object used to write data to the file.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public FileOutputStream openWriteExisting(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.FileOutputStream
object used to write data to the file.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public FileOutputStream openWriteNew(long length) throws StorageException, URISyntaxException
To avoid overwriting and instead throw an error, please use the
openWriteNew(long, AccessCondition, FileRequestOptions, OperationContext)
overload with the appropriate
AccessCondition
.
length
- A long
which represents the length, in bytes, of the stream to create.FileOutputStream
object used to write data to the file.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public FileOutputStream openWriteNew(long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
To avoid overwriting and instead throw an error, please pass in an AccessCondition
generated using
AccessCondition.generateIfNotExistsCondition()
.
length
- A long
which represents the length, in bytes, of the stream to create.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.FileOutputStream
object used to write data to the file.StorageException
- If a storage service error occurred.URISyntaxException
public void uploadFromByteArray(byte[] buffer, int offset, int length) throws StorageException, IOException, URISyntaxException
buffer
- A byte
array which represents the data to write to the file.offset
- A int
which represents the offset of the byte array from which to start the data upload.length
- An int
which represents the number of bytes to upload from the input buffer.StorageException
- If a storage service error occurred.IOException
URISyntaxException
public void uploadFromByteArray(byte[] buffer, int offset, int length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException
buffer
- A byte
array which represents the data to write to the file.offset
- A int
which represents the offset of the byte array from which to start the data upload.length
- An int
which represents the number of bytes to upload from the input buffer.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.IOException
URISyntaxException
public void uploadFromFile(String path) throws StorageException, IOException, URISyntaxException
path
- A String
which represents the path to the file to be uploaded.StorageException
- If a storage service error occurred.IOException
URISyntaxException
public void uploadFromFile(String path, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException
path
- A String
which represents the path to the file to be uploaded.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.IOException
URISyntaxException
public void uploadText(String content) throws StorageException, IOException, URISyntaxException
content
- A String
which represents the content that will be uploaded to the file.StorageException
- If a storage service error occurred.IOException
URISyntaxException
public void uploadText(String content, String charsetName, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException
content
- A String
which represents the content that will be uploaded to the file.charsetName
- A String
which represents the name of the charset to use to encode the content.
If null, the platform's default encoding is used.accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.IOException
URISyntaxException
@DoesServiceRequest public void uploadRange(InputStream sourceStream, long offset, long length) throws StorageException, IOException, URISyntaxException
sourceStream
- An InputStream
object which represents the input stream to write to the file.offset
- A long
which represents the offset, in number of bytes, at which to begin writing the
data.length
- A long
which represents the length, in bytes, of the data to write.IOException
- If an I/O exception occurred.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void uploadRange(InputStream sourceStream, long offset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException
sourceStream
- An InputStream
object which represents the input stream to write to the file.offset
- A long
which represents the offset, in number of bytes, at which to begin writing the
data.length
- A long
which represents the length, in bytes, of the data to write.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.IOException
- If an I/O exception occurred.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void uploadMetadata() throws StorageException, URISyntaxException
Use downloadAttributes()
to retrieve the latest values for the file's properties and metadata
from the Microsoft Azure storage service.
StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
Use downloadAttributes()
to retrieve the latest values for the file's properties and metadata
from the Microsoft Azure storage service.
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void uploadProperties() throws StorageException, URISyntaxException
Use downloadAttributes()
to retrieve the latest values for the file's properties and metadata
from the Microsoft Azure storage service.
StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public final void uploadProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
Use downloadAttributes()
to retrieve the latest values for the file's properties and metadata
from the Microsoft Azure storage service.
accessCondition
- An AccessCondition
object that represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object that represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
public void resize(long size) throws StorageException, URISyntaxException
size
- A long
which represents the size of the file, in bytes.StorageException
- If a storage service error occurred.URISyntaxException
public void resize(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, URISyntaxException
size
- A long
which represents the size of the file, in bytes.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void upload(InputStream sourceStream, long length) throws StorageException, IOException, URISyntaxException
sourceStream
- An InputStream
object to read from.length
- A long
which represents the length, in bytes, of the stream data. Must be non zero.IOException
- If an I/O exception occurred.StorageException
- If a storage service error occurred.URISyntaxException
@DoesServiceRequest public void upload(InputStream sourceStream, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException
sourceStream
- An InputStream
object to read from.length
- A long
which represents the length, in bytes, of the stream data. This must be greater than
or equal to zero.accessCondition
- An AccessCondition
object which represents the access conditions for the file.options
- A FileRequestOptions
object that specifies any additional options for the request. Specifying
null
will use the default request options from the associated service client (
CloudFileClient
).opContext
- An OperationContext
object which represents the context for the current operation. This object
is used to track requests to the storage service, and to provide additional runtime information about
the operation.IOException
- If an I/O exception occurred.StorageException
- If a storage service error occurred.URISyntaxException
public final CloudFileShare getShare() throws StorageException, URISyntaxException
getShare
in interface ListFileItem
CloudFileShare
object that represents the share of the file.StorageException
- If a storage service error occurred.URISyntaxException
- If the resource URI is invalid.public final HashMap<String,String> getMetadata()
java.util.HashMap
object that represents the metadata for the file.public final String getName()
String
that represents the name of the file.public final CloudFileDirectory getParent() throws URISyntaxException, StorageException
getParent
in interface ListFileItem
CloudFileDirectory
object that represents the parent directory for the file.StorageException
- If a storage service error occurred.URISyntaxException
- If the resource URI is invalid.public final FileProperties getProperties()
FileProperties
object that represents the properties of the file.public final CloudFileClient getServiceClient()
CloudFileClient
object that represents the client.public final int getStreamWriteSizeInBytes()
FileOutputStream
.int
which represents the number of bytes to buffer.public final int getStreamMinimumReadSizeInBytes()
FileInputStream
.int
which represents the minimum read size, in bytes, when using a FileInputStream
object.public final StorageUri getStorageUri()
getStorageUri
in interface ListFileItem
StorageUri
that represents the list of URIs for all locations.public final URI getUri()
getUri
in interface ListFileItem
java.net.URI
object that represents the URI for the file.public final void setMetadata(HashMap<String,String> metadata)
metadata
- A java.util.HashMap
object that contains the metadata being assigned to the file.public void setStreamMinimumReadSizeInBytes(int minimumReadSize)
FileInputStream
.minimumReadSize
- An int
that represents the minimum number of bytes to buffer when reading from
a file while using a FileInputStream
object. Must be greater than or equal to 16 KB.IllegalArgumentException
- If minimumReadSize
is less than 16 KB.public void setStreamWriteSizeInBytes(int streamWriteSizeInBytes)
FileOutputStream
.streamWriteSizeInBytes
- An int
which represents the number of bytes to buffer while using a
FileOutputStream
object, ranging from 512 bytes to 4 MB, inclusive.IllegalArgumentException
- If streamWriteSizeInBytes
is less than 512 bytes or greater than 4 MB.Copyright © 2018. All Rights Reserved.