CloudFile Class
- java.
lang. Object - ListFileItem
- com.
microsoft. azure. storage. file. CloudFile
- com.
public class CloudFile implements ListFileItem
Represents a Microsoft Azure File.
Field Summary
Modifier and Type | Field and Description |
---|---|
Cloud |
fileServiceClient
Represents the file service client. |
Cloud |
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. |
Result |
closeAllHandlesSegmented()
Close all SMB handles on this file. |
Result |
closeAllHandlesSegmented(final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Close all SMB handles on this file. |
Result |
closeHandleSegmented(String handleID)
Close all SMB handles on this file. |
Result |
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<File |
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<File |
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 "?". |
Copy |
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 Cloud |
getParent()
Returns the file item's parent. |
String |
getParentNameFromURI(final StorageUri resourceAddress, final CloudFileShare share)
Retrieves the parent name for a file URI. |
final File |
getProperties()
Returns the file's properties. |
final Cloud |
getServiceClient()
Returns the file service client associated with the file. |
final Cloud |
getShare()
Returns the file's share. |
final Storage |
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 Storage |
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<File |
listHandles()
Gets the SMB handles open on this file. |
Iterable<File |
listHandles(FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file. |
Result |
listHandlesSegmented()
Gets the SMB handles open on this file. |
Result |
listHandlesSegmented(final Integer maxResults, final ResultContinuation continuationToken, FileRequestOptions options, OperationContext opContext)
Gets the SMB handles open on this file. |
final File |
openRead()
Opens a file input stream to download the file. Use setStreamMinimumReadSizeInBytes(final int minimumReadSize) to configure the read size. |
final File |
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. |
File |
openWriteExisting()
Opens an output stream object to write data to the file. The file must already exist and any existing data may be overwritten. |
File |
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. |
File |
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. |
File |
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:
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:
Throws:
CloudFile
public CloudFile(final StorageUri fileAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute StorageUri and credentials.
Parameters:
Throws:
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:
String
that represents the name of the file.
CloudFile
public CloudFile(final URI fileAbsoluteUri)
Creates an instance of the class using the specified absolute URI.
Parameters:
java.net.URI
object that represents the absolute URI to the file.
Throws:
CloudFile
public CloudFile(final URI fileAbsoluteUri, final StorageCredentials credentials)
Creates an instance of the class using the specified absolute URI and credentials.
Parameters:
java.net.URI
object that represents the absolute URI to the file.
Throws:
Method Details
abortCopy
public final void abortCopy(final String copyId)
Aborts an ongoing Azure File copy operation.
Parameters:
String
object that identifies the copy operation.
Throws:
abortCopy
public final void abortCopy(final String copyId, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Aborts an ongoing Azure File copy operation.
Parameters:
String
object that identifies the copy operation.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
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:
Throws:
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:
long
which represents the offset, in bytes, at which to begin clearing.
long
which represents the length, in bytes, of the data range to be cleared.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
closeAllHandlesSegmented
public ResultSegment
Close all SMB handles on this file.
Returns:
Throws:
closeAllHandlesSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
closeHandleSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
Returns:
Throws:
closeHandleSegmented
public ResultSegment
Close all SMB handles on this file.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
Throws:
create
public void create(final long size)
Creates a file. If the file already exists, this will replace it.
Parameters:
long
which represents the size, in bytes, of the file.
Throws:
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:
long
which represents the size, in bytes, of the file.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
delete
public final void delete()
Deletes the file.
Throws:
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:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
deleteIfExists
public final boolean deleteIfExists()
Deletes the file if it exists.
Returns:
true
if the file was deleted; otherwise, false
.
Throws:
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:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the file existed and was deleted; otherwise, false
Throws:
download
public final void download(final OutputStream outStream)
Downloads the contents of a file to a stream.
Parameters:
OutputStream
object that represents the target stream.
Throws:
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:
OutputStream
object that represents the target stream.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
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:
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:
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
downloadFileRanges
public ArrayList
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:
ArrayList
object which represents the set of file ranges and their starting and ending byte offsets.Throws:
downloadFileRanges
public ArrayList
Returns a collection of file ranges and their starting and ending byte offsets using the specified request options and operation context.
Parameters:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
ArrayList
object which represents the set of file ranges and their starting and ending byte offsets.Throws:
downloadRange
public final void downloadRange(final long offset, final Long length, final OutputStream outStream)
Downloads the contents of a file to a stream.
Parameters:
long
which represents the offset to use as the starting point for the source.
Long
which represents the number of bytes to read or null
.
OutputStream
object that represents the target stream.
Throws:
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:
long
which represents the offset to use as the starting point for the source.
Long
which represents the number of bytes to read or null
.
OutputStream
object that represents the target stream.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
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:
long
which represents the offset within the file to begin downloading.
Long
which represents the number of bytes to read.
byte
array which represents the buffer to write to.
int
which represents the offset in the byte buffer to begin writing.
Throws:
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:
long
which represents the byte offset to use as the starting point for the source.
Long
which represents the number of bytes to read or null.
byte
array which represents the buffer to which the file bytes are downloaded.
int
which represents the byte offset to use as the starting point for the target.
Throws:
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:
long
which represents the byte offset to use as the starting point for the source.
Long
which represents the number of bytes to read or null
.
byte
array which represents the buffer to which the file bytes are downloaded.
int
which represents the byte offset to use as the starting point for the target.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
downloadText
public String downloadText()
Downloads a file to a string using the platform's default encoding.
Returns:
String
which represents the file's contents.Throws:
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:
String
which represents the name of the charset to use to encode the content. If null, the platform's default encoding is used.
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
String
which represents the file's contents.Throws:
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:
byte
array which represents the buffer to which the file bytes are downloaded.
int
which represents the byte offset to use as the starting point for the target.
Throws:
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:
byte
array which represents the buffer to which the file bytes are downloaded.
long
which represents the byte offset to use as the starting point for the target.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
downloadToFile
public void downloadToFile(final String path)
Downloads a file.
Parameters:
String
which represents the path to the file that will be created.
Throws:
downloadToFile
public void downloadToFile(final String path, final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
Downloads a file.
Parameters:
String
which represents the path to the file that will be created.
null
will use the default request options from the associated service client ( CloudFileClient).
Throws:
exists
public final boolean exists()
Checks to see if the file exists.
Returns:
true
if the file exists, otherwise false
.
Throws:
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:
null
will use the default request options from the associated service client ( CloudFileClient).
Returns:
true
if the file exists, otherwise false
.
Throws:
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:
SharedAccessFilePolicy
object that represents the access policy for the shared access signature.
SharedAccessFileHeaders
object that represents the optional header values to set for a file accessed with this shared access signature.
String
that represents the share-level access policy.
Returns:
String
that represents the shared access signature.Throws:
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:
SharedAccessFilePolicy
object that represents the access policy for the shared access signature.
SharedAccessFileHeaders
object that represents the optional header values to set for a file accessed with this shared access signature.
String
that represents the share-level access policy.
Returns:
String
that represents the shared access signature.Throws:
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:
SharedAccessFilePolicy
object that represents the access policy for the shared access signature.
String
that represents the share-level access policy.
Returns:
String
that represents the shared access signature.Throws:
getCopyState
public CopyState getCopyState()
Returns the Azure File's copy state.
Returns:
getMetadata
public final HashMap
Returns the metadata for the file.
Returns:
java.util.HashMap
object that represents the metadata for the file.getName
public final String getName()
Returns the name of the file.
Returns:
String
that represents the name of the file.getParent
public final CloudFileDirectory getParent()
Returns the file item's parent.
Overrides:
CloudFile.getParent()Returns:
Throws:
getParentNameFromURI
protected static String getParentNameFromURI(final StorageUri resourceAddress, final CloudFileShare share)
Retrieves the parent name for a file URI.
Parameters:
Returns:
String
which represents the parent address for a file URI.Throws:
getProperties
public final FileProperties getProperties()
Returns the file's properties.
Returns:
getServiceClient
public final CloudFileClient getServiceClient()
Returns the file service client associated with the file.
Returns:
getShare
public final CloudFileShare getShare()
Returns the file's share.
Overrides:
CloudFile.getShare()Returns:
Throws:
getStorageUri
public final StorageUri getStorageUri()
Returns the list of URIs for all locations.
Overrides:
CloudFile.getStorageUri()Returns:
getStreamMinimumReadSizeInBytes
public final int getStreamMinimumReadSizeInBytes()
Returns the minimum read size when using a FileInputStream.
Returns:
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:
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:
Returns:
Throws:
getUri
public final URI getUri()
Returns the URI for this file.
Overrides:
CloudFile.getUri()Returns:
java.net.URI
object that represents the URI for the file.listHandles
public Iterable
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
Azure SDK for Java