Skip to content

Commit 0e75bdb

Browse files
committed
Fix inline=false bug
1 parent 0bf94a0 commit 0e75bdb

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

app/jvm/src/main/scala/app/controllers/Application.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package app.controllers
22

3+
import scala.concurrent.ExecutionContext.Implicits.global
34
import akka.stream.scaladsl.StreamConverters
45
import java.io.InputStream
56
import java.nio.charset.StandardCharsets
@@ -32,8 +33,6 @@ final class Application @Inject() (implicit
3233

3334
def getAttachment(contentHash: String, typeEncoded: String, filename: String) = AuthenticatedAction {
3435
implicit user => implicit request =>
35-
val contentType = typeEncoded.replace('>', '/')
36-
3736
val folder = playConfiguration.get[String]("app.accounting.attachmentsFolder")
3837
val folderPath = Paths.get(folder)
3938

@@ -44,17 +43,7 @@ final class Application @Inject() (implicit
4443
} else if (Files.isDirectory(assetPath)) {
4544
NotFound(s"Could not find $assetPath")
4645
} else {
47-
val connection = assetPath.toFile.toURI.toURL.openConnection()
48-
val stream = connection.getInputStream
49-
val source = StreamConverters.fromInputStream(() => stream)
50-
RangeResult
51-
.ofSource(
52-
entityLength = stream.available(), // TODO: This may not be entirely accurate
53-
source = source,
54-
rangeHeader = request.headers.get(RANGE),
55-
fileName = Some(filename),
56-
contentType = Some(contentType),
57-
)
46+
Ok.sendPath(assetPath, inline = true, fileName = _ => Some(filename))
5847
}
5948
}
6049
}

0 commit comments

Comments
 (0)