Skip to content

Commit

Permalink
adding overload with context for getOutputStream (#35749)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimrabab committed Jul 6, 2023
1 parent dc114e6 commit def50c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,27 @@ public BlobOutputStream getBlobOutputStream(ParallelTransferOptions parallelTran
* @throws BlobStorageException If a storage service error occurred.
*/
public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options) {
return getBlobOutputStream(options, null);
}

/**
* Creates and opens an output stream to write data to the block blob. If the blob already exists on the service, it
* will be overwritten.
* <p>
* To avoid overwriting, pass "*" to {@link BlobRequestConditions#setIfNoneMatch(String)}.
* <p>
* Note: We recommend you call write with reasonably sized buffers, you can do so by wrapping the BlobOutputStream
* obtained below with a {@link java.io.BufferedOutputStream}.
*
* @param options {@link BlockBlobOutputStreamOptions}
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return A {@link BlobOutputStream} object used to write data to the blob.
* @throws BlobStorageException If a storage service error occurred.
*/
public BlobOutputStream getBlobOutputStream(BlockBlobOutputStreamOptions options, Context context) {
BlobAsyncClient blobClient = prepareBuilder().buildAsyncClient();

return BlobOutputStream.blockBlobOutputStream(blobClient, options, null);
return BlobOutputStream.blockBlobOutputStream(blobClient, options, context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,24 @@ public OutputStream getOutputStream() {
* @throws DataLakeStorageException If a storage service error occurred.
*/
public OutputStream getOutputStream(DataLakeFileOutputStreamOptions options) {
return getOutputStream(options, null);
}

/**
* Creates and opens an output stream to write data to the file. If the file already exists on the service, it
* will be overwritten.
* <p>
* To avoid overwriting, pass "*" to {@link DataLakeRequestConditions#setIfNoneMatch(String)}.
* </p>
*
* @param options {@link DataLakeFileOutputStreamOptions}
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return The {@link OutputStream} that can be used to write to the file.
* @throws DataLakeStorageException If a storage service error occurred.
*/
public OutputStream getOutputStream(DataLakeFileOutputStreamOptions options, Context context) {
BlockBlobOutputStreamOptions convertedOptions = Transforms.toBlockBlobOutputStreamOptions(options);
return blockBlobClient.getBlobOutputStream(convertedOptions);
return blockBlobClient.getBlobOutputStream(convertedOptions, context);
}

/**
Expand Down

0 comments on commit def50c9

Please sign in to comment.