public class CloudFile extends Object implements ListFileItem
| Modifier and Type | Field and Description |
|---|---|
protected CloudFileClient |
fileServiceClient
Represents the file service client.
|
protected CloudFileDirectory |
parent
Represents the file's directory reference.
|
protected int |
streamMinimumReadSizeInBytes
Holds the minimum read size when using a
FileInputStream. |
protected int |
streamWriteSizeInBytes
Holds the number of bytes to buffer when writing to a
FileOutputStream. |
| Constructor and Description |
|---|
CloudFile(CloudFile otherFile)
Creates an instance of the
CloudFile class by copying values from another cloud file. |
CloudFile(StorageUri fileAbsoluteUri,
CloudFileClient client)
Creates an instance of the
CloudFile class using the specified URI and storage service client. |
CloudFile(StorageUri fileAbsoluteUri,
CloudFileClient client,
CloudFileShare share)
Creates an instance of the
CloudFile class using the specified absolute StorageUri, storage
service client and share. |
CloudFile(URI fileAbsoluteUri,
CloudFileClient client)
Creates an instance of the
CloudFile class using the specified absolute URI and storage service
client. |
CloudFile(URI fileAbsoluteUri,
CloudFileClient client,
CloudFileShare share)
Creates an instance of the
CloudFile class using the specified absolute URI, storage service
client and share. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected int |
downloadRangeInternal(long fileOffset,
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.
|
int |
downloadRangeToByteArray(long offset,
Long length,
byte[] buffer,
int bufferOffet)
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 bufferOffet)
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.
|
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.
|
protected static String |
getParentNameFromURI(StorageUri resourceAddress,
CloudFileShare share)
Retrieves the parent name for a file URI.
|
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. |
protected StorageUri |
getTransformedAddress(OperationContext opContext)
Returns the transformed URI for the resource if the given credentials require transformation.
|
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.
|
protected void |
setProperties(FileProperties properties)
Sets the properties for the file.
|
protected void |
setShare(CloudFileShare share)
Sets the share for the file.
|
protected void |
setStorageUri(StorageUri storageUri)
Sets the list of URIs for all locations.
|
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
FileOutoutStream. |
protected void |
updateEtagAndLastModifiedFromResponse(HttpURLConnection request) |
protected void |
updateLengthFromResponse(HttpURLConnection request) |
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 file.
|
void |
uploadFromFile(String path,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
Uploads a file from a 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.
|
protected int streamWriteSizeInBytes
FileOutputStream.protected int streamMinimumReadSizeInBytes
FileInputStream.protected CloudFileDirectory parent
protected CloudFileClient fileServiceClient
public CloudFile(URI fileAbsoluteUri, CloudFileClient client) throws StorageException, URISyntaxException
CloudFile class using the specified absolute URI and storage service
client.fileAbsoluteUri - A java.net.URI object that represents the absolute URI to the file.client - A CloudFileClient object that specifies the endpoint for the File service.StorageException - If a storage service error occurred.URISyntaxExceptionpublic CloudFile(StorageUri fileAbsoluteUri, CloudFileClient client) throws StorageException, URISyntaxException
CloudFile class using the specified URI and storage service client.fileAbsoluteUri - A StorageUri object that represents the absolute URI to the file.client - A CloudFileClient object that specifies the endpoint for the File service.StorageException - If a storage service error occurred.URISyntaxExceptionpublic CloudFile(URI fileAbsoluteUri, CloudFileClient client, CloudFileShare share) throws StorageException, URISyntaxException
CloudFile class using the specified absolute URI, storage service
client and share.fileAbsoluteUri - A java.net.URI object that represents the absolute URI to the file.client - A CloudFileClient object that specifies the endpoint for the File service.share - A CloudFileShare object that represents the share to use for the file.StorageException - If a storage service error occurred.URISyntaxExceptionpublic CloudFile(StorageUri fileAbsoluteUri, CloudFileClient client, CloudFileShare share) throws StorageException, URISyntaxException
CloudFile class using the specified absolute StorageUri, storage
service client and share.fileAbsoluteUri - A StorageUri object that represents the absolute URI to the file.client - A CloudFileClient object that specifies the endpoint for the File service.share - A CloudFileShare object that represents the share to use for the file.StorageException - If a storage service error occurred.URISyntaxExceptionpublic CloudFile(CloudFile otherFile)
CloudFile class by copying values from another cloud file.otherFile - A CloudFile object that represents the file to copy.@DoesServiceRequest public void clearRange(long offset, long length) throws StorageException
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.@DoesServiceRequest public void clearRange(long offset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.@DoesServiceRequest public void create(long size) throws StorageException
size - A long which represents the size, in bytes, of the file.StorageException - If a storage service error occurred.@DoesServiceRequest public void create(long size, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.@DoesServiceRequest public final void delete() throws StorageException
StorageException - If a storage service error occurred.@DoesServiceRequest public final void delete(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.StorageException - If a storage service error occurred.@DoesServiceRequest public final boolean deleteIfExists() throws StorageException
true if the file was deleted; otherwise, false.StorageException - If a storage service error occurred.@DoesServiceRequest public final boolean deleteIfExists(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 existed and was deleted; otherwise, falseStorageException - If a storage service error occurred.@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 protected final int downloadRangeInternal(long fileOffset, Long length, byte[] buffer, int bufferOffset, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.StorageException - an exception representing any error which occurred during the operation.@DoesServiceRequest public final int downloadRangeToByteArray(long offset, Long length, byte[] buffer, int bufferOffet) 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.bufferOffet - 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 bufferOffet) throws StorageException
buffer - A byte array which represents the buffer to which the file bytes are downloaded.bufferOffet - 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.bufferOffet - 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.IOExceptionpublic 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.IOExceptionpublic String downloadText() throws StorageException, IOException
String which represents the file's contents.StorageException - If a storage service error occurred.IOExceptionpublic 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.@DoesServiceRequest public final FileInputStream openRead() throws StorageException
Use CloudFileClient#setStreamMinimumReadSizeInBytes 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 CloudFileClient#setStreamMinimumReadSizeInBytes 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
FileOutputStream object used to write data to the file.StorageException - If a storage service error occurred.@DoesServiceRequest public FileOutputStream openWriteExisting(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.FileOutputStream object used to write data to the file.StorageException - If a storage service error occurred.@DoesServiceRequest public FileOutputStream openWriteNew(long length) throws StorageException
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.@DoesServiceRequest public FileOutputStream openWriteNew(long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.public void uploadFromByteArray(byte[] buffer,
int offset,
int length)
throws StorageException,
IOException
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.IOExceptionpublic void uploadFromByteArray(byte[] buffer,
int offset,
int length,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
throws StorageException,
IOException
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.IOExceptionpublic void uploadFromFile(String path) throws StorageException, IOException
path - A String which represents the path to the file to be uploaded.StorageException - If a storage service error occurred.IOExceptionpublic void uploadFromFile(String path, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
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.IOExceptionpublic void uploadText(String content) throws StorageException, IOException
content - A String which represents the content that will be uploaded to the file.StorageException - If a storage service error occurred.IOExceptionpublic void uploadText(String content, String charsetName, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
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@DoesServiceRequest public void uploadRange(InputStream sourceStream, long offset, long length) throws StorageException, IOException
sourceStream - An IntputStream 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.@DoesServiceRequest public void uploadRange(InputStream sourceStream, long offset, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
sourceStream - An IntputStream 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.@DoesServiceRequest public final void uploadMetadata() throws StorageException
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.@DoesServiceRequest public final void uploadMetadata(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.@DoesServiceRequest public final void uploadProperties() throws StorageException
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.@DoesServiceRequest public final void uploadProperties(AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException
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.public void resize(long size)
throws StorageException
size - A long which represents the size of the file, in bytes.StorageException - If a storage service error occurred.public void resize(long size,
AccessCondition accessCondition,
FileRequestOptions options,
OperationContext opContext)
throws StorageException
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.@DoesServiceRequest public void upload(InputStream sourceStream, long length) throws StorageException, IOException
sourceStream - An IntputStream 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.@DoesServiceRequest public void upload(InputStream sourceStream, long length, AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext) throws StorageException, IOException
sourceStream - An IntputStream object to read from.length - A long which represents the length, in bytes, of the stream data. This must be great than
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.protected static String getParentNameFromURI(StorageUri resourceAddress, CloudFileShare share) throws URISyntaxException
resourceAddress - A StorageUri object which represents the resource URI.delimiter - A String which specifies the directory delimiter to use.usePathStyleUris - A Boolean which specifies whether path style URIs are used.share - A CloudFileShare object which represents the file share.String which represents the parent address for a file URI.URISyntaxExceptionprotected void updateEtagAndLastModifiedFromResponse(HttpURLConnection request)
protected void updateLengthFromResponse(HttpURLConnection request)
public final CloudFileShare getShare() throws StorageException, URISyntaxException
getShare in interface ListFileItemCloudFileShare 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 ListFileItemCloudFileDirectory 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 ListFileItemStorageUri that represents the list of URIs for all locations.public final URI getUri()
getUri in interface ListFileItemjava.net.URI object that represents the URI for the file.protected final void setShare(CloudFileShare share)
share - A CloudFileShare object that represents the share being assigned to 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.protected final void setProperties(FileProperties properties)
properties - A FileProperties object that represents the properties being assigned to the file.protected void setStorageUri(StorageUri storageUri)
storageUri - A StorageUri that represents the list of URIs for all locations.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)
FileOutoutStream.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.protected final StorageUri getTransformedAddress(OperationContext opContext) throws URISyntaxException, StorageException
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.StorageUri object that represents the transformed URI.StorageException - If a storage service error occurred.URISyntaxException - If the resource URI is invalid./**
* Copyright Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/