Skip to content

Commit

Permalink
rename "putBlob" to "putBlockBlob" akka#3253
Browse files Browse the repository at this point in the history
  • Loading branch information
sfali committed Aug 28, 2024
1 parent cf48d55 commit c10b3d1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ object AzureStorageStream {
.mapMaterializedValue(_ => NotUsed)
}

private[storage] def putBlob(objectPath: String,
httpEntity: UniversalEntity,
headers: Seq[HttpHeader]): Source[Option[ObjectMetadata], NotUsed] = {
private[storage] def putBlockBlob(objectPath: String,
httpEntity: UniversalEntity,
headers: Seq[HttpHeader]): Source[Option[ObjectMetadata], NotUsed] = {
Source
.fromMaterializer { (mat, attr) =>
implicit val system: ActorSystem = mat.system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ object BlobService {
.asJava

/**
* Put blob.
* Put Block blob.
*
* @param objectPath path of the object, should start with "/" and separated by `/`, e.g. `/container/blob`
* @param contentType content type of the blob
Expand All @@ -131,13 +131,13 @@ object BlobService {
* @return A [[akka.stream.javadsl.Source Source]] containing an [[scala.Option]] of
* [[akka.stream.alpakka.azure.storage.ObjectMetadata]], will be [[scala.None]] in case the object does not exist
*/
def putBlob(objectPath: String,
contentType: ContentType,
contentLength: Long,
payload: Source[ByteString, _],
leaseId: Optional[String]): Source[Optional[ObjectMetadata], NotUsed] =
def putBlockBlob(objectPath: String,
contentType: ContentType,
contentLength: Long,
payload: Source[ByteString, _],
leaseId: Optional[String]): Source[Optional[ObjectMetadata], NotUsed] =
AzureStorageStream
.putBlob(
.putBlockBlob(
objectPath,
HttpEntity(contentType.asInstanceOf[ScalaContentType], contentLength, payload.asScala),
StorageHeaders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object BlobService {
StorageHeaders().withLeaseIdHeader(leaseId).headers)

/**
* Put blob.
* Put Block blob.
*
* @param objectPath path of the object, should start with "/" and separated by `/`, e.g. `/container/blob`
* @param contentType content type of the blob
Expand All @@ -85,12 +85,12 @@ object BlobService {
* @return A [[akka.stream.scaladsl.Source Source]] containing an [[scala.Option]] of
* [[akka.stream.alpakka.azure.storage.ObjectMetadata]], will be [[scala.None]] in case the object does not exist
*/
def putBlob(objectPath: String,
contentType: ContentType = ContentTypes.`application/octet-stream`,
contentLength: Long,
payload: Source[ByteString, _],
leaseId: Option[String] = None): Source[Option[ObjectMetadata], NotUsed] =
AzureStorageStream.putBlob(
def putBlockBlob(objectPath: String,
contentType: ContentType = ContentTypes.`application/octet-stream`,
contentLength: Long,
payload: Source[ByteString, _],
leaseId: Option[String] = None): Source[Option[ObjectMetadata], NotUsed] =
AzureStorageStream.putBlockBlob(
objectPath,
HttpEntity(contentType, contentLength, payload),
StorageHeaders()
Expand Down
6 changes: 3 additions & 3 deletions azure-storage/src/test/java/docs/javadsl/StorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ public void createContainer() throws Exception {
public void putBlob() throws Exception {
mockPutBlob();

//#put-blob
//#put-block-blob
final Source<Optional<ObjectMetadata>, NotUsed> source =
BlobService.putBlob(containerName() + "/" + blobName(),
BlobService.putBlockBlob(containerName() + "/" + blobName(),
ContentTypes.TEXT_PLAIN_UTF8,
contentLength(),
Source.single(ByteString.fromString(payload())),
Optional.empty());

final CompletionStage<Optional<ObjectMetadata>> optionalCompletionStage = source.runWith(Sink.head(), system);
//#put-blob
//#put-block-blob

final var optionalObjectMetadata = optionalCompletionStage.toCompletableFuture().get();
Assert.assertTrue(optionalObjectMetadata.isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait StorageIntegrationSpec
"put blob" in {
val maybeObjectMetadata =
BlobService
.putBlob(
.putBlockBlob(
objectPath = objectPath,
contentType = ContentTypes.`text/plain(UTF-8)`,
contentLength = contentLength,
Expand Down
6 changes: 3 additions & 3 deletions azure-storage/src/test/scala/docs/scaladsl/StorageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ class StorageSpec
"put blob" ignore {
mockPutBlob()

//#put-blob
//#put-block-blob
import akka.stream.alpakka.azure.storage.scaladsl.BlobService
import akka.stream.alpakka.azure.storage.ObjectMetadata

val source: Source[Option[ObjectMetadata], NotUsed] =
BlobService.putBlob(
BlobService.putBlockBlob(
objectPath = s"$containerName/$blobName",
contentType = ContentTypes.`text/plain(UTF-8)`,
contentLength = contentLength,
payload = Source.single(ByteString(payload))
)

val eventualMaybeMetadata: Future[Option[ObjectMetadata]] = source.runWith(Sink.head)
//#put-blob
//#put-block-blob

val maybeObjectMetadata = eventualMaybeMetadata.futureValue
maybeObjectMetadata shouldBe defined
Expand Down
8 changes: 4 additions & 4 deletions docs/src/main/paradox/azure-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ Scala
Java
: @@snip [snip](/azure-storage/src/test/java/docs/javadsl/StorageTest.java) { #create-container }

### Put Blob
### Put Block Blob

The [`Put Blob`](https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob) operation creates a new block, page, or append blob, or updates the content of an existing block blob.
The [`Put Block Blob`](https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob) operation creates a new block or updates the content of an existing block blob.

Scala
: @@snip [snip](/azure-storage/src/test/scala/docs/scaladsl/StorageSpec.scala) { #put-blob }
: @@snip [snip](/azure-storage/src/test/scala/docs/scaladsl/StorageSpec.scala) { #put-block-blob }

Java
: @@snip [snip](/azure-storage/src/test/java/docs/javadsl/StorageTest.java) { #put-blob }
: @@snip [snip](/azure-storage/src/test/java/docs/javadsl/StorageTest.java) { #put-block-blob }

### Get Blob

Expand Down

0 comments on commit c10b3d1

Please sign in to comment.