danieln
danieln

Reputation: 4973

REST File uploading - multipart or just sending content on inputstream

I need to write REST resource that should receive a file and save it to the disk.
The files will be sent from jersey client.
For now, I see two options:
1. Using multipart
2. Just reading the inputstream as a string and saving it to a file.

What are the pros of using multipart? is it related to file size? or anything else?

Thanks

Upvotes: 2

Views: 3931

Answers (1)

Carlo Pellegrini
Carlo Pellegrini

Reputation: 5686

If you use Jersey server side, using multipart you gain

  • disk buffering (surely you don't want to retain huge files in memory)
  • automatic base64/binary stream conversion

If you choose the String option these benefits are unavailable.

See also my answer to the question JAX-RS Accept Images as input, there is a sample implementation of the multipart option

Upvotes: 2

Related Questions