Skip to content

Commit c22a65a

Browse files
committed
Use numerics
1 parent 3e5c5b2 commit c22a65a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

image-api/src/main/scala/no/ndla/imageapi/controller/RawController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class RawController(using
180180
}
181181
imageStorage
182182
.uploadFromStream(
183-
s"${image.fileShortName}_width=${imageParams.width}_height=${imageParams.height}.${image.format}",
183+
s"${image.fileShortName}_width=${imageParams.width.getOrElse(0)}_height=${imageParams.height.getOrElse(0)}.${image.format}",
184184
resized.get.stream,
185185
resized.get.contentType,
186186
resized.get.contentLength

image-api/src/main/scala/no/ndla/imageapi/model/domain/ImageStream.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ trait ImageStream {
1717
def stream: InputStream
1818
def fileName: String
1919
def fileShortName: String = fileName.substring(0, fileName.lastIndexOf("."))
20-
def format: String = fileName.substring(fileName.lastIndexOf(".") + 1)
20+
def format: String = fileName.substring(fileName.lastIndexOf(".") + 1)
2121
lazy val sourceImage: BufferedImage
2222
}

image-api/src/main/scala/no/ndla/imageapi/service/ImageStorageService.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ class ImageStorageService(using
6262
}
6363

6464
def get(imageKey: String, imageParams: ImageParams): Try[(ImageStream, Boolean)] = {
65-
val lastPeriod = imageKey.lastIndexOf(".")
66-
val (pre, post) = imageKey.splitAt(lastPeriod)
67-
val maybeFileName = s"${pre}_width=${imageParams.width}_height=${imageParams.height}${post}"
65+
val lastPeriod = imageKey.lastIndexOf(".")
66+
val (pre, post) = imageKey.splitAt(lastPeriod)
67+
val maybeFileName =
68+
s"${pre}_width=${imageParams.width.getOrElse(0)}_height=${imageParams.height.getOrElse(0)}${post}"
6869
if (head(maybeFileName)) {
6970
getObject(maybeFileName, true)
7071
} else {

0 commit comments

Comments
 (0)