CloudFile Class

  • java.lang.Object

public class CloudFile implements ListFileItem

Represents a Microsoft Azure File.

Field Summary

Modifier and Type Field and Description
CloudFileClient fileServiceClient

Represents the file service client.

CloudFileDirectory parent

Represents the file's directory reference.

int streamMinimumReadSizeInBytes

Holds the minimum read size when using a FileInputStream.

int streamWriteSizeInBytes

Holds the number of bytes to buffer when writing to a FileOutputStream.

Constructor Summary

Constructor Description
CloudFile(final CloudFile otherFile)

Creates an instance of the class by copying values from another cloud file.

CloudFile(final StorageUri fileAbsoluteUri)

Creates an instance of the class using the specified absolute StorageUri.

CloudFile(final StorageUri fileAbsoluteUri, final StorageCredentials credentials)

Creates an instance of the class using the specified absolute StorageUri and credentials.

CloudFile(final StorageUri uri, final String fileName, final CloudFileShare share)

Creates an instance of the class using the specified address, share, and client.

CloudFile(final URI fileAbsoluteUri)

Creates an instance of the class using the specified absolute URI.

CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials)

Creates an instance of the class using the specified absolute URI and credentials.

Method Summary

Modifier and Type Method and Description
final void abortCopy(final String copyId)

Aborts an ongoing Azure File copy operation.

final void abortCopy(final String copyId, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Aborts an ongoing Azure File copy operation.

void assertValidFilePermissionOrKey()

Verifies that the directory's filePermission and properties.filePermissionKey are both not set.

void clearRange(final long offset, final long length)

Clears a range from a file.

Calling releases the storage space used by the specified range. Ranges that have been cleared are no longer tracked as part of the file.

void clearRange(final long offset, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Clears a range from a file using the specified lease ID, request options, and operation context.

Calling releases the storage space used by the specified range. Ranges that have been cleared are no longer tracked as part of the file.

ResultSegment<Integer> closeAllHandlesSegmented()

Close all SMB handles on this file.

ResultSegment<Integer> closeAllHandlesSegmented(final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Close all SMB handles on this file.

ResultSegment<Integer> closeHandleSegmented(String handleID)

Close all SMB handles on this file.

ResultSegment<Integer> closeHandleSegmented(String handleID, ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Close all SMB handles on this file.

void create(final long size)

Creates a file. If the file already exists, this will replace it.

void create(final long size, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Creates a file using the specified access condition, request options and operation context. If the file already exists, this will replace it.

final void delete()

Deletes the file.

final void delete(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Deletes the file using the specified access condition, request options, and operation context.

final boolean deleteIfExists()

Deletes the file if it exists.

final boolean deleteIfExists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Deletes the file if it exists, using the specified access condition, request options, and operation context.

final void download(final OutputStream outStream)

Downloads the contents of a file to a stream.

final void download(final OutputStream outStream, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads the contents of a file to a stream using the specified request options and operation context.

final void downloadAttributes()

Populates a file's properties and metadata.

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.

final void downloadAttributes(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Populates a file's properties and metadata using the specified request options and operation context.

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.

ArrayList<FileRange> downloadFileRanges()

Returns a collection of file ranges and their starting and ending byte offsets.

The start and end byte offsets for each file range are inclusive.

ArrayList<FileRange> downloadFileRanges(final 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.

final void downloadRange(final long offset, final Long length, final OutputStream outStream)

Downloads the contents of a file to a stream.

final void downloadRange(final long offset, final Long length, final OutputStream outStream, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads the contents of a file to a stream using the specified request options and operation context.

final int downloadRangeInternal(final long fileOffset, final Long length, final byte[] buffer, final int bufferOffset, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a range of bytes from the file to the given byte buffer.

final int downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the file to the given byte buffer.

final int downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset, final 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(final String charsetName, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a file to a string using the specified encoding.

final int downloadToByteArray(final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the file to the given byte buffer.

final int downloadToByteArray(final byte[] buffer, final int bufferOffset, final 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(final String path)

Downloads a file.

void downloadToFile(final String path, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a file.

final boolean exists()

Checks to see if the file exists.

final boolean exists(final 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(final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers, final String groupPolicyIdentifier)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

CopyState getCopyState()

Returns the Azure File's copy state.

final HashMap<String, String> getMetadata()

Returns the metadata for the file.

final String getName()

Returns the name of the file.

final CloudFileDirectory getParent()

Returns the file item's parent.

String getParentNameFromURI(final StorageUri resourceAddress, final CloudFileShare share)

Retrieves the parent name for a file URI.

final FileProperties getProperties()

Returns the file's properties.

final CloudFileClient getServiceClient()

Returns the file service client associated with the file.

final CloudFileShare getShare()

Returns the file's share.

final StorageUri getStorageUri()

Returns the list of URIs for all locations.

final int getStreamMinimumReadSizeInBytes()

Returns the minimum read size when using a FileInputStream.

final int getStreamWriteSizeInBytes()

Gets the number of bytes to buffer when writing to a FileOutputStream.

final StorageUri getTransformedAddress(final OperationContext opContext)

Returns the transformed URI for the resource if the given credentials require transformation.

final URI getUri()

Returns the URI for this file.

Iterable<FileHandle> listHandles()

Gets the SMB handles open on this file.

Iterable<FileHandle> listHandles(FileRequestOptions options, OperationContext opContext)

Gets the SMB handles open on this file.

ResultSegment<FileHandle> listHandlesSegmented()

Gets the SMB handles open on this file.

ResultSegment<FileHandle> listHandlesSegmented(final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Gets the SMB handles open on this file.

final FileInputStream openRead()

Opens a file input stream to download the file.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

final FileInputStream openRead(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Opens a file input stream to download the file using the specified request options and operation context.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

FileOutputStream openWriteExisting()

Opens an output stream object to write data to the file. The file must already exist and any existing data may be overwritten.

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. The file must already exist and any existing data may be overwritten.

FileOutputStream openWriteNew(final long length)

Opens an output stream object to write data to the file. The file does not yet exist and will be created with the length specified. If the file already exists on the service, it will be overwritten.

To avoid overwriting and instead throw an error, please use the openWriteNew(final long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition.

FileOutputStream openWriteNew(final 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. The file does not need to yet exist and will be created with the length specified. If the file already exists on the service, it will be overwritten.

To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition().

void putRangeFromURL(final long destOffset, final long length, final URI sourceUri, final long sourceOffset)

Uploads a range from one file to another file.

void putRangeFromURL(final long destOffset, final long length, final URI sourceUri, final long sourceOffset, FileRequestOptions options, OperationContext opContext)

Uploads a range from one file to another 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 setFilePermission(String filePermission)

Sets the file's file permission to set

final void setMetadata(final HashMap<String, String> metadata)

Sets the metadata for the file.

final void setProperties(final FileProperties properties)

Sets the properties for the file.

final void setShare(final CloudFileShare share)

Sets the share for the file.

void setStorageUri(final StorageUri storageUri)

Sets the list of URIs for all locations.

void setStreamMinimumReadSizeInBytes(final int minimumReadSize)

Sets the minimum read size when using a FileInputStream.

void setStreamWriteSizeInBytes(final int streamWriteSizeInBytes)

Sets the number of bytes to buffer when writing to a FileOutputStream.

final String startCopy(final CloudBlob sourceBlob)

Requests the service to start copying a blob's contents, properties, and metadata to a new file.

final String startCopy(final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, final 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.

final String startCopy(final CloudFile sourceFile)

Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File.

final String startCopy(final CloudFile sourceFile, final AccessCondition sourceAccessCondition, final 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.

final String startCopy(final URI source)

Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File.

final String startCopy(final URI source, final AccessCondition sourceAccessCondition, final 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 updateEtagAndLastModifiedFromResponse(HttpURLConnection request)
void updateLengthFromResponse(HttpURLConnection request)
void upload(final InputStream sourceStream, final long length)

Uploads the source stream data to the file. If the file already exists on the service, it will be overwritten.

void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the source stream data to the file using the specified access condition, request options, and operation context. If the file already exists on the service, it will be overwritten.

void uploadFromByteArray(final byte[] buffer, final int offset, final int length)

Uploads a file from data in a byte array. If the file already exists on the service, it will be overwritten.

void uploadFromByteArray(final byte[] buffer, final int offset, final int length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from data in a byte array. If the file already exists on the service, it will be overwritten.

void uploadFromFile(final String path)

Uploads a local file. If the file already exists on the service, it will be overwritten.

void uploadFromFile(final String path, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from a local file. If the file already exists on the service, it will be overwritten.

final void uploadMetadata()

Uploads the file's metadata to the storage service.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

final void uploadMetadata(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the file's metadata to the storage service using the access condition, request options, and operation context.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

final void uploadProperties()

Uploads the file's properties to the storage service.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

final void uploadProperties(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the file's properties using the access condition, request options, and operation context.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

void uploadRange(final InputStream sourceStream, final long offset, final long length)

Uploads a range to a file.

void uploadRange(final InputStream sourceStream, final long offset, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a range to a file using the specified lease ID, request options, and operation context.

void uploadText(final String content)

Uploads a file from a string using the platform's default encoding. If the file already exists on the service, it will be overwritten.

void uploadText(final String content, final String charsetName, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from a string using the specified encoding. If the file already exists on the service, it will be overwritten.

Field Details

fileServiceClient

protected CloudFileClient fileServiceClient

Represents the file service client.

parent

protected CloudFileDirectory parent

Represents the file's directory reference.

streamMinimumReadSizeInBytes

protected int streamMinimumReadSizeInBytes= Constants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES

Holds the minimum read size when using a FileInputStream.

streamWriteSizeInBytes

protected int streamWriteSizeInBytes= Constants.DEFAULT_STREAM_WRITE_IN_BYTES

Holds the number of bytes to buffer when writing to a FileOutputStream.

Constructor Details

CloudFile

public CloudFile(final CloudFile otherFile)

Creates an instance of the class by copying values from another cloud file.

Parameters:

otherFile - A CloudFile object that represents the file to copy.

CloudFile

public CloudFile(final StorageUri fileAbsoluteUri)

Creates an instance of the class using the specified absolute StorageUri.

Parameters:

fileAbsoluteUri - A StorageUri object that represents the absolute URI to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

CloudFile

public CloudFile(final StorageUri fileAbsoluteUri, final StorageCredentials credentials)

Creates an instance of the class using the specified absolute StorageUri and credentials.

Parameters:

fileAbsoluteUri - A StorageUri object that represents the absolute URI to the file.
credentials - A StorageCredentials object used to authenticate access.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

CloudFile

protected CloudFile(final StorageUri uri, final String fileName, final CloudFileShare share)

Creates an instance of the class using the specified address, share, and client.

Parameters:

uri - A StorageUri that represents the file directory's address.
fileName - A String that represents the name of the file.
share - A CloudFileShare object that represents the associated file share.

CloudFile

public CloudFile(final URI fileAbsoluteUri)

Creates an instance of the class using the specified absolute URI.

Parameters:

fileAbsoluteUri - A java.net.URI object that represents the absolute URI to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

CloudFile

public CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials)

Creates an instance of the class using the specified absolute URI and credentials.

Parameters:

fileAbsoluteUri - A java.net.URI object that represents the absolute URI to the file.
credentials - A StorageCredentials object used to authenticate access.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

Method Details

abortCopy

public final void abortCopy(final String copyId)

Aborts an ongoing Azure File copy operation.

Parameters:

copyId - A String object that identifies the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

abortCopy

public final void abortCopy(final String copyId, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Aborts an ongoing Azure File copy operation.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

assertValidFilePermissionOrKey

protected void assertValidFilePermissionOrKey()

Verifies that the directory's filePermission and properties.filePermissionKey are both not set.

clearRange

public void clearRange(final long offset, final long length)

Clears a range from a file.

Calling releases the storage space used by the specified range. Ranges that have been cleared are no longer tracked as part of the file.

Parameters:

offset - The offset, in bytes, at which to begin clearing.
length - The length, in bytes, of the data range to be cleared.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

clearRange

public void clearRange(final long offset, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Clears a range from a file using the specified lease ID, request options, and operation context.

Calling releases the storage space used by the specified range. Ranges that have been cleared are no longer tracked as part of the file.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

closeAllHandlesSegmented

public ResultSegment closeAllHandlesSegmented()

Close all SMB handles on this file.

Returns:

A ResultSegment<T> which has one element which is the number of handles closed and a continuation to follow in case the operation took too long to be completed atomically.

Throws:

StorageException

closeAllHandlesSegmented

public ResultSegment closeAllHandlesSegmented(final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Close all SMB handles on this file.

Parameters:

continuationToken - A ResultContinuation object that represents a continuation token returned by a previous listing operation.
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.

Returns:

A ResultSegment<T> which has one element which is the number of handles closed and a continuation to follow in case the operation took too long to be completed atomically.

Throws:

StorageException

closeHandleSegmented

public ResultSegment closeHandleSegmented(String handleID)

Close all SMB handles on this file.

Parameters:

handleID - The handle to close.

Returns:

A ResultSegment<T> which has one element which is the number of handles closed and a continuation to follow in case the operation took too long to be completed atomically.

Throws:

StorageException

closeHandleSegmented

public ResultSegment closeHandleSegmented(String handleID, ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Close all SMB handles on this file.

Parameters:

handleID - The handle to close.
continuationToken - A ResultContinuation object that represents a continuation token returned by a previous listing operation.
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.

Returns:

A ResultSegment<T> which has one element which is the number of handles closed and a continuation to follow in case the operation took too long to be completed atomically.

Throws:

StorageException

create

public void create(final long size)

Creates a file. If the file already exists, this will replace it.

Parameters:

size - A long which represents the size, in bytes, of the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

create

public void create(final long size, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Creates a file using the specified access condition, request options and operation context. If the file already exists, this will replace it.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

delete

public final void delete()

Deletes the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

delete

public final void delete(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Deletes the file using the specified access condition, request options, and operation context.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

deleteIfExists

public final boolean deleteIfExists()

Deletes the file if it exists.

Returns:

true if the file was deleted; otherwise, false.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

deleteIfExists

public final boolean deleteIfExists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Deletes the file if it exists, using the specified access condition, request options, and operation context.

Parameters:

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.

Returns:

true if the file existed and was deleted; otherwise, false

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

download

public final void download(final OutputStream outStream)

Downloads the contents of a file to a stream.

Parameters:

outStream - An OutputStream object that represents the target stream.

Throws:

StorageException - If a storage service error occurred.

download

public final void download(final OutputStream outStream, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads the contents of a file to a stream using the specified request options and operation context.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadAttributes

public final void downloadAttributes()

Populates a file's properties and metadata.

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.

Throws:

StorageException - If a storage service error occurred.

downloadAttributes

public final void downloadAttributes(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Populates a file's properties and metadata using the specified request options and operation context.

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.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadFileRanges

public ArrayList downloadFileRanges()

Returns a collection of file ranges and their starting and ending byte offsets.

The start and end byte offsets for each file range are inclusive.

Returns:

An ArrayList object which represents the set of file ranges and their starting and ending byte offsets.

Throws:

StorageException - If a storage service error occurred.

downloadFileRanges

public ArrayList downloadFileRanges(final 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.

Parameters:

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.

Returns:

An ArrayList object which represents the set of file ranges and their starting and ending byte offsets.

Throws:

StorageException - If a storage service error occurred.

downloadRange

public final void downloadRange(final long offset, final Long length, final OutputStream outStream)

Downloads the contents of a file to a stream.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadRange

public final void downloadRange(final long offset, final Long length, final OutputStream outStream, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads the contents of a file to a stream using the specified request options and operation context.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadRangeInternal

protected final int downloadRangeInternal(final long fileOffset, final Long length, final byte[] buffer, final int bufferOffset, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a range of bytes from the file to the given byte buffer.

Parameters:

fileOffset - A long which represents the offset within the file to begin downloading.
length - A Long which represents the number of bytes to read.
buffer - A byte array which represents the buffer to write to.
bufferOffset - An int which represents the offset in the byte buffer to begin writing.
accessCondition - An AccessCondition object that represents the access conditions for the file.
options - A FileRequestOptions object that specifies any additional options for the request.
opContext - An OperationContext object used to track the execution of the operation.

Throws:

StorageException - an exception representing any error which occurred during the operation.

downloadRangeToByteArray

public final int downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the file to the given byte buffer.

Parameters:

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.

Throws:

StorageException

downloadRangeToByteArray

public final int downloadRangeToByteArray(final long offset, final Long length, final byte[] buffer, final int bufferOffset, final 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.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadText

public String downloadText()

Downloads a file to a string using the platform's default encoding.

Returns:

A String which represents the file's contents.

Throws:

StorageException - If a storage service error occurred.
IOException

downloadText

public String downloadText(final String charsetName, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a file to a string using the specified encoding.

Parameters:

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.

Returns:

A String which represents the file's contents.

Throws:

StorageException - If a storage service error occurred.
IOException

downloadToByteArray

public final int downloadToByteArray(final byte[] buffer, final int bufferOffset)

Downloads a range of bytes from the file to the given byte buffer.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadToByteArray

public final int downloadToByteArray(final byte[] buffer, final int bufferOffset, final 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.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.

downloadToFile

public void downloadToFile(final String path)

Downloads a file.

Parameters:

path - A String which represents the path to the file that will be created.

Throws:

StorageException - If a storage service error occurred.
IOException

downloadToFile

public void downloadToFile(final String path, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Downloads a file.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
IOException

exists

public final boolean exists()

Checks to see if the file exists.

Returns:

true if the file exists, otherwise false.

Throws:

StorageException - If a storage service error occurred.

exists

public final boolean exists(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Checks to see if the file exists, using the specified access condition, request options and operation context.

Parameters:

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.

Returns:

true if the file exists, otherwise false.

Throws:

StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers, final String groupPolicyIdentifier)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

Parameters:

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.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final SharedAccessFileHeaders headers, final String groupPolicyIdentifier, final IPRange ipRange, final SharedAccessProtocols protocols)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

Parameters:

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.

Returns:

A String that represents the shared access signature.

Throws:

IllegalArgumentException - If the credentials are invalid.
InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

generateSharedAccessSignature

public String generateSharedAccessSignature(final SharedAccessFilePolicy policy, final String groupPolicyIdentifier)

Returns a shared access signature for the file using the specified group policy identifier and shared access file headers. Note this does not contain the leading "?".

Parameters:

policy - A SharedAccessFilePolicy object that represents the access policy for the shared access signature.
groupPolicyIdentifier - A String that represents the share-level access policy.

Returns:

A String that represents the shared access signature.

Throws:

InvalidKeyException - If the credentials are invalid.
StorageException - If a storage service error occurred.

getCopyState

public CopyState getCopyState()

Returns the Azure File's copy state.

Returns:

A CopyState object that represents the copy state of the file.

getMetadata

public final HashMap getMetadata()

Returns the metadata for the file.

Returns:

A java.util.HashMap object that represents the metadata for the file.

getName

public final String getName()

Returns the name of the file.

Returns:

A String that represents the name of the file.

getParent

public final CloudFileDirectory getParent()

Returns the file item's parent.

Overrides:

CloudFile.getParent()

Returns:

A CloudFileDirectory object that represents the parent directory for the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getParentNameFromURI

protected static String getParentNameFromURI(final StorageUri resourceAddress, final CloudFileShare share)

Retrieves the parent name for a file URI.

Parameters:

resourceAddress - A StorageUri object which represents the resource URI.
share - A CloudFileShare object which represents the file share.

Returns:

A String which represents the parent address for a file URI.

Throws:

URISyntaxException

getProperties

public final FileProperties getProperties()

Returns the file's properties.

Returns:

A FileProperties object that represents the properties of the file.

getServiceClient

public final CloudFileClient getServiceClient()

Returns the file service client associated with the file.

Returns:

A CloudFileClient object that represents the client.

getShare

public final CloudFileShare getShare()

Returns the file's share.

Overrides:

CloudFile.getShare()

Returns:

A CloudFileShare object that represents the share of the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getStorageUri

public final StorageUri getStorageUri()

Returns the list of URIs for all locations.

Overrides:

CloudFile.getStorageUri()

Returns:

A StorageUri that represents the list of URIs for all locations.

getStreamMinimumReadSizeInBytes

public final int getStreamMinimumReadSizeInBytes()

Returns the minimum read size when using a FileInputStream.

Returns:

A int which represents the minimum read size, in bytes, when using a FileInputStream object.

getStreamWriteSizeInBytes

public final int getStreamWriteSizeInBytes()

Gets the number of bytes to buffer when writing to a FileOutputStream.

Returns:

A int which represents the number of bytes to buffer.

getTransformedAddress

protected final StorageUri getTransformedAddress(final OperationContext opContext)

Returns the transformed URI for the resource if the given credentials require transformation.

Parameters:

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.

Returns:

A StorageUri object that represents the transformed URI.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException - If the resource URI is invalid.

getUri

public final URI getUri()

Returns the URI for this file.

Overrides:

CloudFile.getUri()

Returns:

A java.net.URI object that represents the URI for the file.

listHandles

public Iterable listHandles()

Gets the SMB handles open on this file.

Returns:

AnIterable 

</code> of the handles that will lazily request new segments. </p>

listHandles

public Iterable listHandles(FileRequestOptions options, OperationContext opContext)

Gets the SMB handles open on this file.

Parameters:

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.

Returns:

AnIterable 

</code> of the handles that will lazily request new segments. </p>

listHandlesSegmented

public ResultSegment listHandlesSegmented()

Gets the SMB handles open on this file.

Returns:

A ResultSegment<T> object that contains a segment of the enumerable collection of ListFileItem objects that represent the files and directories.

Throws:

StorageException

listHandlesSegmented

public ResultSegment listHandlesSegmented(final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)

Gets the SMB handles open on this file.

Parameters:

maxResults - The maximum number of results to retrieve. If null or greater than 5000, the server will return up to 5,000 items. Must be at least 1.
continuationToken - A ResultContinuation object that represents a continuation token returned by a previous listing operation.
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.

Returns:

A ResultSegment<T> object that contains a segment of the enumerable collection of ListFileItem objects that represent the files and directories.

Throws:

StorageException

openRead

public final FileInputStream openRead()

Opens a file input stream to download the file.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

Returns:

An InputStream object that represents the stream to use for reading from the file.

Throws:

StorageException - If a storage service error occurred.

openRead

public final FileInputStream openRead(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Opens a file input stream to download the file using the specified request options and operation context.

Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size.

Parameters:

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.

Returns:

An InputStream object that represents the stream to use for reading from the file.

Throws:

StorageException - If a storage service error occurred.

openWriteExisting

public FileOutputStream openWriteExisting()

Opens an output stream object to write data to the file. The file must already exist and any existing data may be overwritten.

Returns:

A FileOutputStream object used to write data to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

openWriteExisting

public 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. The file must already exist and any existing data may be overwritten.

Parameters:

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.

Returns:

A FileOutputStream object used to write data to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

openWriteNew

public FileOutputStream openWriteNew(final long length)

Opens an output stream object to write data to the file. The file does not yet exist and will be created with the length specified. If the file already exists on the service, it will be overwritten.

To avoid overwriting and instead throw an error, please use the openWriteNew(final long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) overload with the appropriate AccessCondition.

Parameters:

length - A long which represents the length, in bytes, of the stream to create.

Returns:

A FileOutputStream object used to write data to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

openWriteNew

public FileOutputStream openWriteNew(final 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. The file does not need to yet exist and will be created with the length specified. If the file already exists on the service, it will be overwritten.

To avoid overwriting and instead throw an error, please pass in an AccessCondition generated using generateIfNotExistsCondition().

Parameters:

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.

Returns:

A FileOutputStream object used to write data to the file.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

putRangeFromURL

public void putRangeFromURL(final long destOffset, final long length, final URI sourceUri, final long sourceOffset)

Uploads a range from one file to another file.

Parameters:

destOffset - 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 and read.
sourceUri - A java.net.URI object that specifies the source URI.
sourceOffset - A long which represents the offset, in number of bytes, at which to begin reading the data.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

putRangeFromURL

public void putRangeFromURL(final long destOffset, final long length, final URI sourceUri, final long sourceOffset, FileRequestOptions options, OperationContext opContext)

Uploads a range from one file to another file using the specified lease ID, request options, and operation context

Parameters:

destOffset - 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 and read.
sourceUri - A java.net.URI object that specifies the source URI.
sourceOffset - A long which represents the offset, in number of bytes, at which to begin reading the data.
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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

resize

public void resize(long size)

Resizes the file to the specified size.

Parameters:

size - A long which represents the size of the file, in bytes.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

resize

public void resize(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Resizes the file to the specified size.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

setFilePermission

public void setFilePermission(String filePermission)

Sets the file's file permission to set

Parameters:

filePermission - A String that represents the file's file permission to set.

setMetadata

public final void setMetadata(final HashMap metadata)

Sets the metadata for the file.

Parameters:

metadata - A java.util.HashMap object that contains the metadata being assigned to the file.

setProperties

protected final void setProperties(final FileProperties properties)

Sets the properties for the file.

Parameters:

properties - A FileProperties object that represents the properties being assigned to the file.

setShare

protected final void setShare(final CloudFileShare share)

Sets the share for the file.

Parameters:

share - A CloudFileShare object that represents the share being assigned to the file.

setStorageUri

protected void setStorageUri(final StorageUri storageUri)

Sets the list of URIs for all locations.

Parameters:

storageUri - A StorageUri that represents the list of URIs for all locations.

setStreamMinimumReadSizeInBytes

public void setStreamMinimumReadSizeInBytes(final int minimumReadSize)

Sets the minimum read size when using a FileInputStream.

Parameters:

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.

Throws:

IllegalArgumentException - If minimumReadSize is less than 16 KB.

setStreamWriteSizeInBytes

public void setStreamWriteSizeInBytes(final int streamWriteSizeInBytes)

Sets the number of bytes to buffer when writing to a FileOutputStream.

Parameters:

streamWriteSizeInBytes - An int which represents the number of bytes to buffer while using a FileOutputStream object, ranging from 512 bytes to 4 MB, inclusive.

Throws:

IllegalArgumentException - If streamWriteSizeInBytes is less than 512 bytes or greater than 4 MB.

startCopy

public final String startCopy(final CloudBlob sourceBlob)

Requests the service to start copying a blob's contents, properties, and metadata to a new file.

Parameters:

sourceBlob - A CloudBlob object that represents the source blob to copy.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

startCopy

public final String startCopy(final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, final 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.

Parameters:

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.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

startCopy

public final String startCopy(final CloudFile sourceFile)

Requests the service to start copying an Azure File's contents, properties, and metadata to a new Azure File.

Parameters:

sourceFile - A CloudFile object that represents the source Azure File to copy.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

startCopy

public final String startCopy(final CloudFile sourceFile, final AccessCondition sourceAccessCondition, final 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.

Parameters:

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.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

startCopy

public final String startCopy(final URI source)

Requests the service to start copying a URI's contents, properties, and metadata to a new Azure File.

Parameters:

source - The source's java.net.URI.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

startCopy

public final String startCopy(final URI source, final AccessCondition sourceAccessCondition, final 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.

Parameters:

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.

Returns:

A String which represents the copy ID associated with the copy operation.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

updateEtagAndLastModifiedFromResponse

protected void updateEtagAndLastModifiedFromResponse(HttpURLConnection request)

Parameters:

request

updateLengthFromResponse

protected void updateLengthFromResponse(HttpURLConnection request)

Parameters:

request

upload

public void upload(final InputStream sourceStream, final long length)

Uploads the source stream data to the file. If the file already exists on the service, it will be overwritten.

Parameters:

sourceStream - An InputStream object to read from.
length - A long which represents the length, in bytes, of the stream data. Must be non zero.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.
URISyntaxException

upload

public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the source stream data to the file using the specified access condition, request options, and operation context. If the file already exists on the service, it will be overwritten.

Parameters:

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.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.
URISyntaxException

uploadFromByteArray

public void uploadFromByteArray(final byte[] buffer, final int offset, final int length)

Uploads a file from data in a byte array. If the file already exists on the service, it will be overwritten.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

uploadFromByteArray

public void uploadFromByteArray(final byte[] buffer, final int offset, final int length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from data in a byte array. If the file already exists on the service, it will be overwritten.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

uploadFromFile

public void uploadFromFile(final String path)

Uploads a local file. If the file already exists on the service, it will be overwritten.

Parameters:

path - A String which represents the path to the file to be uploaded.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

uploadFromFile

public void uploadFromFile(final String path, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from a local file. If the file already exists on the service, it will be overwritten.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

uploadMetadata

public final void uploadMetadata()

Uploads the file's metadata to the storage service.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

uploadMetadata

public final void uploadMetadata(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the file's metadata to the storage service using the access condition, request options, and operation context.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

uploadProperties

public final void uploadProperties()

Uploads the file's properties to the storage service.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

uploadProperties

public final void uploadProperties(final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads the file's properties using the access condition, request options, and operation context.

Use downloadAttributes() to retrieve the latest values for the file's properties and metadata from the Microsoft Azure storage service.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
URISyntaxException

uploadRange

public void uploadRange(final InputStream sourceStream, final long offset, final long length)

Uploads a range to a file.

Parameters:

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.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.
URISyntaxException

uploadRange

public void uploadRange(final InputStream sourceStream, final long offset, final long length, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a range to a file using the specified lease ID, request options, and operation context.

Parameters:

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.

Throws:

IOException - If an I/O exception occurred.
StorageException - If a storage service error occurred.
URISyntaxException

uploadText

public void uploadText(final String content)

Uploads a file from a string using the platform's default encoding. If the file already exists on the service, it will be overwritten.

Parameters:

content - A String which represents the content that will be uploaded to the file.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

uploadText

public void uploadText(final String content, final String charsetName, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)

Uploads a file from a string using the specified encoding. If the file already exists on the service, it will be overwritten.

Parameters:

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.

Throws:

StorageException - If a storage service error occurred.
IOException
URISyntaxException

Applies to