End-point to support the file upload

Can anyone please show how to create the end-point that accepts the file upload, please?

I found the following example but not quite sure how to relate this to Lagom, but this example deviates from the general Lagom practice and uses Play framework’s controller to handle the file.

https://www.playframework.com/documentation/2.6.x/ScalaFileUpload

If I create an end-point definition with the following Request type that accepts the array of bytes, will it work?

case class IdentityDocument(documentType: IdDocumentType,
                            willSendLater: Boolean,
                            document: Array[Byte])

Thanks,

@lejoow there is one lagom Recipe describing this use case

thanks Alan. I saw this too but I am looking for more Lagom native solution for it. ie. without having to create a separate play controller if possible.

@lejoow lagom is not designed for file upload use case and this is a reason why there is no Lagom native way.

2 Likes

I’ve managed to do this by making the end-point to accept the base64 decoded String - this means that the String will be about 30% bigger than the actual file size, but for my need, this is more than enough.

Thanks,