jersey
  1. jersey
  2. JERSEY-777

Provide support for byte[] in FormDataBodyPart

    Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1.10
    • Component/s: core
    • Labels:
      None

      Description

      I think it would be nice if we could have an additional support for byte[] instead of just flat File objects in FormDataBodyPart, as there are situations in which we don't need to hit the disk before sending the data through the wire.

      According to the javadoc (http://jersey.java.net/nonav/apidocs/1.9.1/contribs/jersey-multipart/com/sun/jersey/multipart/file/FileDataBodyPart.html) there is currently only a File object support.

      Support for byte[] could be implemented as another subclass of the FormDataBodyPart.

      Mailing list:
      http://java.net/projects/jersey/lists/users/archive/2011-09/message/114

      1. JERSEY-777.diff
        23 kB
        Piotr Nowicki
      2. JERSEY-777-tests.diff
        24 kB
        Piotr Nowicki

        Activity

        Hide
        Piotr Nowicki added a comment -

        There could be also support for Stream parameters (either in the same class or in another subclass).

        Show
        Piotr Nowicki added a comment - There could be also support for Stream parameters (either in the same class or in another subclass).
        Hide
        Piotr Nowicki added a comment -

        Adds:

        • the StreamDataBodyPart which supports the InputStream as a multipart/form-data body part entity,
        • the StreamDataBodyPartTest which defines a set of tests for StreamDataBodyPart,
        • modified package-info.java to reflect the support for different file representations.
        Show
        Piotr Nowicki added a comment - Adds: the StreamDataBodyPart which supports the InputStream as a multipart/form-data body part entity, the StreamDataBodyPartTest which defines a set of tests for StreamDataBodyPart, modified package-info.java to reflect the support for different file representations.
        Hide
        Jakub Podlesak added a comment -

        The patch provided by Pedro Kowalski should also work as a fix for the original issue,
        as ByteArrayInputStream could be used to encapsulate the original byte array.

        Show
        Jakub Podlesak added a comment - The patch provided by Pedro Kowalski should also work as a fix for the original issue, as ByteArrayInputStream could be used to encapsulate the original byte array.
        Hide
        Jakub Podlesak added a comment -

        Fixed in the main trunk

        Show
        Jakub Podlesak added a comment - Fixed in the main trunk
        Hide
        Piotr Nowicki added a comment -

        I've added tests for multipart by using Grizzly server with the deployed endpoint. Don't know how to add a file when the ticket is already closed, so I've put the diff at gist: https://gist.github.com/1305267

        Cheers!

        Show
        Piotr Nowicki added a comment - I've added tests for multipart by using Grizzly server with the deployed endpoint. Don't know how to add a file when the ticket is already closed, so I've put the diff at gist: https://gist.github.com/1305267 Cheers!
        Hide
        Jakub Podlesak added a comment -

        Re-opened, so that Pedro is able to attach the additional tests.

        Show
        Jakub Podlesak added a comment - Re-opened, so that Pedro is able to attach the additional tests.
        Hide
        Piotr Nowicki added a comment -

        Tests for the previous enhancement.

        Show
        Piotr Nowicki added a comment - Tests for the previous enhancement.

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            Piotr Nowicki
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: