public class BlobClient extends BlobClientBase
This client is instantiated through BlobClientBuilder
or retrieved via
getBlobClient
.
For operations on a specific blob type (i.e append, block, or page) use
getAppendBlobClient
, getBlockBlobClient
, or
getPageBlobClient
to construct a client that allows blob specific operations.
Please refer to the Azure Docs for more information.
Modifier | Constructor and Description |
---|---|
protected |
BlobClient(BlobAsyncClient client)
Protected constructor for use by
BlobClientBuilder . |
Modifier and Type | Method and Description |
---|---|
AppendBlobClient |
getAppendBlobClient()
Creates a new
AppendBlobClient associated to this blob. |
BlockBlobClient |
getBlockBlobClient()
Creates a new
BlockBlobClient associated to this blob. |
PageBlobClient |
getPageBlobClient()
Creates a new
PageBlobClient associated to this blob. |
BlobClient |
getSnapshotClient(String snapshot)
Creates a new
BlobClient linked to the snapshot of this blob resource. |
void |
uploadFromFile(String filePath)
Creates a new block blob.
|
void |
uploadFromFile(String filePath,
boolean overwrite)
Creates a new block blob, or updates the content of an existing block blob.
|
void |
uploadFromFile(String filePath,
ParallelTransferOptions parallelTransferOptions,
BlobHttpHeaders headers,
Map<String,String> metadata,
AccessTier tier,
BlobRequestConditions accessConditions,
Duration timeout)
Creates a new block blob, or updates the content of an existing block blob.
|
abortCopyFromUrl, abortCopyFromUrlWithResponse, beginCopy, beginCopy, copyFromUrl, copyFromUrlWithResponse, createSnapshot, createSnapshotWithResponse, delete, deleteWithResponse, download, downloadToFile, downloadToFileWithResponse, downloadWithResponse, exists, existsWithResponse, getAccountInfo, getAccountInfoWithResponse, getAccountName, getBlobName, getBlobUrl, getContainerName, getCustomerProvidedKey, getHttpPipeline, getProperties, getPropertiesWithResponse, getServiceVersion, getSnapshotId, isSnapshot, openInputStream, openInputStream, setAccessTier, setAccessTierWithResponse, setHttpHeaders, setHttpHeadersWithResponse, setMetadata, setMetadataWithResponse, undelete, undeleteWithResponse
protected BlobClient(BlobAsyncClient client)
BlobClientBuilder
.client
- the async blob clientpublic BlobClient getSnapshotClient(String snapshot)
BlobClient
linked to the snapshot
of this blob resource.getSnapshotClient
in class BlobClientBase
snapshot
- the identifier for a specific snapshot of this blobBlobClient
used to interact with the specific snapshot.public AppendBlobClient getAppendBlobClient()
AppendBlobClient
associated to this blob.AppendBlobClient
associated to this blob.public BlockBlobClient getBlockBlobClient()
BlockBlobClient
associated to this blob.BlockBlobClient
associated to this blob.public PageBlobClient getPageBlobClient()
PageBlobClient
associated to this blob.PageBlobClient
associated to this blob.public void uploadFromFile(String filePath)
Code Samples
try { client.uploadFromFile(filePath);System
.out.println("Upload from file succeeded"); } catch (UncheckedIOException
ex) {System
.err.printf("Failed to upload from file %s%n", ex.getMessage()); }
filePath
- Path of the file to uploadUncheckedIOException
- If an I/O error occurspublic void uploadFromFile(String filePath, boolean overwrite)
Code Samples
try { boolean overwrite = false; client.uploadFromFile(filePath, overwrite);System
.out.println("Upload from file succeeded"); } catch (UncheckedIOException
ex) {System
.err.printf("Failed to upload from file %s%n", ex.getMessage()); }
filePath
- Path of the file to uploadoverwrite
- Whether or not to overwrite, should the blob already existUncheckedIOException
- If an I/O error occurspublic void uploadFromFile(String filePath, ParallelTransferOptions parallelTransferOptions, BlobHttpHeaders headers, Map<String,String> metadata, AccessTier tier, BlobRequestConditions accessConditions, Duration timeout)
Code Samples
BlobHttpHeaders
headers = newBlobHttpHeaders
() .setContentMd5("data".getBytes(StandardCharsets
.UTF_8)) .setContentLanguage("en-US") .setContentType("binary");Map
<String
,String
> metadata =Collections
.singletonMap("metadata", "value");BlobRequestConditions
accessConditions = newBlobRequestConditions
() .setLeaseId(leaseId) .setIfUnmodifiedSince(OffsetDateTime
.now().minusDays(3));Integer
blockSize = 100 * 1024 * 1024; // 100 MB;ParallelTransferOptions
parallelTransferOptions = newParallelTransferOptions
(blockSize, null, null); try { client.uploadFromFile(filePath, parallelTransferOptions, headers, metadata,AccessTier
.HOT, accessConditions, timeout);System
.out.println("Upload from file succeeded"); } catch (UncheckedIOException
ex) {System
.err.printf("Failed to upload from file %s%n", ex.getMessage()); }
filePath
- Path of the file to uploadparallelTransferOptions
- ParallelTransferOptions
to use to upload from file. Number of parallel
transfers parameter is ignored.headers
- BlobHttpHeaders
metadata
- Metadata to associate with the blob.tier
- AccessTier
for the uploaded blobaccessConditions
- BlobRequestConditions
timeout
- An optional timeout value beyond which a RuntimeException
will be raised.UncheckedIOException
- If an I/O error occursCopyright © 2019 Microsoft Corporation. All rights reserved.