forked from akka/alpakka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
azure-storage/src/main/scala/akka/stream/alpakka/azure/storage/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) since 2016 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.stream.alpakka | ||
package azure | ||
|
||
import java.time.{ZoneOffset, ZonedDateTime} | ||
import java.time.format.DateTimeFormatter | ||
|
||
package object storage { | ||
|
||
private[storage] val NewLine: String = "\n" | ||
private[storage] val AuthorizationHeaderKey = "Authorization" | ||
private[storage] val XmsDateHeaderKey = "x-ms-date" | ||
private[storage] val XmsVersionHeaderKey = "x-ms-version" | ||
private[storage] val BlobTypeHeaderKey = "x-ms-blob-type" | ||
private[storage] val LeaseIdHeaderKey = "x-ms-lease-id" | ||
private[storage] val FileWriteTypeHeaderKey = "x-ms-write" | ||
private[storage] val XMsContentLengthHeaderKey = "x-ms-content-length" | ||
private[storage] val FileTypeHeaderKey = "x-ms-type" | ||
private[storage] val BlobType = "blob" | ||
private[storage] val FileType = "file" | ||
|
||
private[storage] def getFormattedDate: String = | ||
DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC)) | ||
|
||
/** Removes ETag quotes in the same way the official AWS tooling does. See | ||
*/ | ||
private[storage] def removeQuotes(string: String): String = { | ||
val trimmed = string.trim() | ||
val tail = if (trimmed.startsWith("\"")) trimmed.drop(1) else trimmed | ||
if (tail.endsWith("\"")) tail.dropRight(1) else tail | ||
} | ||
|
||
/** This method returns `None` if given an empty `String`. This is typically used when parsing XML since its common to | ||
* have XML elements with an empty text value inside. | ||
*/ | ||
private[storage] def emptyStringToOption(value: String): Option[String] = if (value == "") None else Some(value) | ||
} |