66import com .azure .core .annotation .ReturnType ;
77import com .azure .core .annotation .ServiceClient ;
88import com .azure .core .annotation .ServiceMethod ;
9- import com .azure .core .http .HttpPipeline ;
109import com .azure .core .http .rest .Response ;
1110import com .azure .core .util .BinaryData ;
1211import com .azure .core .util .Context ;
1312import com .azure .core .util .FluxUtil ;
1413import com .azure .core .util .logging .ClientLogger ;
15- import com .azure .storage .blob .implementation .models .EncryptionScope ;
1614import com .azure .storage .blob .implementation .util .ModelHelper ;
1715import com .azure .storage .blob .models .AccessTier ;
18- import com .azure .storage .blob .models .CpkInfo ;
1916import com .azure .storage .blob .models .CustomerProvidedKey ;
2017import com .azure .storage .blob .options .BlobParallelUploadOptions ;
2118import com .azure .storage .blob .models .BlobRequestConditions ;
3532
3633import java .io .InputStream ;
3734import java .io .UncheckedIOException ;
38- import java .nio .channels .AsynchronousFileChannel ;
39- import java .nio .file .Path ;
4035import java .time .Duration ;
4136import java .util .Map ;
4237import java .util .Objects ;
@@ -66,26 +61,19 @@ public class BlobClient extends BlobClientBase {
6661 /**
6762 * The block size to use if none is specified in parallel operations.
6863 */
69- public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = 4 * Constants . MB ;
64+ public static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = BlobAsyncClient . BLOB_DEFAULT_UPLOAD_BLOCK_SIZE ;
7065
7166 /**
7267 * The number of buffers to use if none is specied on the buffered upload method.
7368 */
74- public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERS = 8 ;
69+ public static final int BLOB_DEFAULT_NUMBER_OF_BUFFERS = BlobAsyncClient . BLOB_DEFAULT_NUMBER_OF_BUFFERS ;
7570 /**
7671 * If a blob is known to be greater than 100MB, using a larger block size will trigger some server-side
7772 * optimizations. If the block size is not set and the size of the blob is known to be greater than 100MB, this
7873 * value will be used.
7974 */
80- public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE = 8 * Constants . MB ;
75+ public static final int BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE = BlobAsyncClient . BLOB_DEFAULT_HTBB_UPLOAD_BLOCK_SIZE ;
8176
82- /**
83- * The default block size used in {@link FluxUtil#readFile(AsynchronousFileChannel)}.
84- * This is to make sure we're using same size when using {@link BinaryData#fromFile(Path, int)}
85- * and {@link BinaryData#fromFile(Path, Long, Long, int)}
86- * to represent the content.
87- */
88- private static final int DEFAULT_FILE_READ_CHUNK_SIZE = 1024 * 64 ;
8977 private final BlobAsyncClient client ;
9078
9179 private BlockBlobClient blockBlobClient ;
@@ -101,31 +89,6 @@ protected BlobClient(BlobAsyncClient client) {
10189 this .client = client ;
10290 }
10391
104- /**
105- * Protected constructor for use by {@link BlobClientBuilder}.
106- *
107- * @param client the async blob client
108- * @param pipeline The pipeline used to send and receive service requests.
109- * @param url The endpoint where to send service requests.
110- * @param serviceVersion The version of the service to receive requests.
111- * @param accountName The storage account name.
112- * @param containerName The container name.
113- * @param blobName The blob name.
114- * @param snapshot The snapshot identifier for the blob, pass {@code null} to interact with the blob directly.
115- * @param customerProvidedKey Customer provided key used during encryption of the blob's data on the server, pass
116- * {@code null} to allow the service to use its own encryption.
117- * @param encryptionScope Encryption scope used during encryption of the blob's data on the server, pass
118- * {@code null} to allow the service to use its own encryption.
119- * @param versionId The version identifier for the blob, pass {@code null} to interact with the latest blob version.
120- */
121- protected BlobClient (BlobAsyncClient client , HttpPipeline pipeline , String url , BlobServiceVersion serviceVersion ,
122- String accountName , String containerName , String blobName , String snapshot , CpkInfo customerProvidedKey ,
123- EncryptionScope encryptionScope , String versionId ) {
124- super (client , pipeline , url , serviceVersion , accountName , containerName , blobName , snapshot , customerProvidedKey ,
125- encryptionScope , versionId );
126- this .client = client ;
127- }
128-
12992 /**
13093 * Creates a new {@link BlobClient} linked to the {@code snapshot} of this blob resource.
13194 *
@@ -134,11 +97,7 @@ protected BlobClient(BlobAsyncClient client, HttpPipeline pipeline, String url,
13497 */
13598 @ Override
13699 public BlobClient getSnapshotClient (String snapshot ) {
137- BlobAsyncClient asyncClient = new BlobAsyncClient (getHttpPipeline (), getAccountUrl (), getServiceVersion (),
138- getAccountName (), getContainerName (), getBlobName (), snapshot , getCustomerProvidedKey (),
139- encryptionScope , getVersionId ());
140- return new BlobClient (asyncClient , getHttpPipeline (), getAccountUrl (), getServiceVersion (), getAccountName (),
141- getContainerName (), getBlobName (), snapshot , getCustomerProvidedKey (), encryptionScope , getVersionId ());
100+ return new BlobClient (client .getSnapshotClient (snapshot ));
142101 }
143102
144103 /**
@@ -150,11 +109,7 @@ public BlobClient getSnapshotClient(String snapshot) {
150109 */
151110 @ Override
152111 public BlobClient getVersionClient (String versionId ) {
153- BlobAsyncClient asyncClient = new BlobAsyncClient (getHttpPipeline (), getAccountUrl (), getServiceVersion (),
154- getAccountName (), getContainerName (), getBlobName (), getSnapshotId (), getCustomerProvidedKey (),
155- encryptionScope , versionId );
156- return new BlobClient (asyncClient , getHttpPipeline (), getAccountUrl (), getServiceVersion (), getAccountName (),
157- getContainerName (), getBlobName (), getSnapshotId (), getCustomerProvidedKey (), encryptionScope , versionId );
112+ return new BlobClient (client .getVersionClient (versionId ));
158113 }
159114
160115 /**
@@ -165,13 +120,7 @@ public BlobClient getVersionClient(String versionId) {
165120 */
166121 @ Override
167122 public BlobClient getEncryptionScopeClient (String encryptionScope ) {
168- EncryptionScope finalEncryptionScope = null ;
169- if (encryptionScope != null ) {
170- finalEncryptionScope = new EncryptionScope ().setEncryptionScope (encryptionScope );
171- }
172- return new BlobClient (this .client .getEncryptionScopeAsyncClient (encryptionScope ), getHttpPipeline (),
173- getAccountUrl (), getServiceVersion (), getAccountName (), getContainerName (), getBlobName (), getSnapshotId (),
174- getCustomerProvidedKey (), finalEncryptionScope , getVersionId ());
123+ return new BlobClient (client .getEncryptionScopeAsyncClient (encryptionScope ));
175124 }
176125
177126 /**
@@ -183,16 +132,7 @@ public BlobClient getEncryptionScopeClient(String encryptionScope) {
183132 */
184133 @ Override
185134 public BlobClient getCustomerProvidedKeyClient (CustomerProvidedKey customerProvidedKey ) {
186- CpkInfo finalCustomerProvidedKey = null ;
187- if (customerProvidedKey != null ) {
188- finalCustomerProvidedKey = new CpkInfo ()
189- .setEncryptionKey (customerProvidedKey .getKey ())
190- .setEncryptionKeySha256 (customerProvidedKey .getKeySha256 ())
191- .setEncryptionAlgorithm (customerProvidedKey .getEncryptionAlgorithm ());
192- }
193- return new BlobClient (this .client .getCustomerProvidedKeyAsyncClient (customerProvidedKey ), getHttpPipeline (),
194- getAccountUrl (), getServiceVersion (), getAccountName (), getContainerName (), getBlobName (), getSnapshotId (),
195- finalCustomerProvidedKey , encryptionScope , getVersionId ());
135+ return new BlobClient (client .getCustomerProvidedKeyAsyncClient (customerProvidedKey ));
196136 }
197137
198138 /**
0 commit comments