I am using cropit(http://scottcheng.github.io/cropit/) tool on client side to crop images. It crops images and returns image in 'data:image/png;base64' format. Now i need this to be sent to play framework.
header/payload preview:
------WebKitFormBoundaryXnMMA8dXWah4PjT9
Content-Disposition: form-data; name="question"
test new poll?
------WebKitFormBoundaryXnMMA8dXWah4PjT9
Content-Disposition: form-data; name="pollImageBase64"
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaQAAAExCAYAAAAz59bFAAAgAElEQVR4Xuy9B3Qs53Um+FVVdyN3N3J6iZmi+PgeSTFJtKWRaK9lW+OdXWssUZGUFWdndz1nnY6PPWMfWyOtPeNsS7IpM0mWf
What should be the form mapping?
val newPollForm = Form(
mapping(
"question" -> nonEmptyText,
"pollImageBase64" -> optional(text) //doesn't work and returns none
)(NewPollItem.apply)(NewPollItem.unapply)
)
Once i have received the pollImageBase64 as string of base64, how do i use it and save the image in scala/play framework?