Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Parsing multipart/form-data from request body #6

Open
igniting opened this issue Aug 25, 2013 · 0 comments
Open

Parsing multipart/form-data from request body #6

igniting opened this issue Aug 25, 2013 · 0 comments

Comments

@igniting
Copy link

I was trying to parse request body to multipart/form-data using org.apache.commons.fileupload. For that I needed request content as Array[Byte]. I first used getBytes("UTF-8") on body. This worked fine with text files, but for binary files, this didn't seem to work. On further examination, I noticed that the hex for new file was shifted by some amount.
As a workaround, I changed the type of body to Array[Byte] and made these changes in netty/NettyRequest.scala:

  val contentLength = nettyRequest.getContent.readableBytes
  var byteArray = new Array[Byte](contentLength)
  nettyRequest.getContent.readBytes(byteArray)

  val body = byteArray

This seemed to work fine with any type of file.

damienlevin pushed a commit to damienlevin/smoke that referenced this issue Apr 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant