Package nxt.util

Class MultipartUtility


  • public class MultipartUtility
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      MultipartUtility​(java.net.URL url, java.nio.charset.Charset charset)
      This constructor initializes a new HTTP POST request with content type is set to multipart/form-data
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFilePart​(java.lang.String fieldName, java.lang.String fileName, byte[] data)
      Adds a upload file section to the request
      void addFormField​(java.lang.String name, java.lang.String value)
      Adds a form field to the request
      void addHeaderField​(java.lang.String name, java.lang.String value)
      Adds a header field to the request.
      java.io.InputStream finish()
      Completes the request and receives response from the server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultipartUtility

        public MultipartUtility​(java.net.URL url,
                                java.nio.charset.Charset charset)
        This constructor initializes a new HTTP POST request with content type is set to multipart/form-data
        Parameters:
        url - url
        charset - character set
    • Method Detail

      • addFormField

        public void addFormField​(java.lang.String name,
                                 java.lang.String value)
        Adds a form field to the request
        Parameters:
        name - field name
        value - field value
      • addFilePart

        public void addFilePart​(java.lang.String fieldName,
                                java.lang.String fileName,
                                byte[] data)
        Adds a upload file section to the request
        Parameters:
        fieldName - name attribute in <input type="file" name="..." />
        fileName - name of file
        data - file bytes
      • addHeaderField

        public void addHeaderField​(java.lang.String name,
                                   java.lang.String value)
        Adds a header field to the request. Unused for now.
        Parameters:
        name - - name of the header field
        value - - value of the header field
      • finish

        public java.io.InputStream finish()
        Completes the request and receives response from the server.
        Returns:
        a list of Strings as response in case the server returned status OK, otherwise an exception is thrown.