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

Parsing multipart/form-data from request body #6

@igniting

Description

@igniting

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions