Class MultipartUtility


  • public class MultipartUtility
    extends Object
    OkHttp sending byte[] array not works with vk Using this. Stealed from there.
    • Constructor Detail

      • MultipartUtility

        public MultipartUtility​(String requestURL)
        This constructor initializes a new HTTP POST request with content type is set to multipart/form-data
        Parameters:
        requestURL - request link
    • Method Detail

      • addFilePart

        public void addFilePart​(String fieldName,
                                File uploadFile)
        Adds a upload file section to the request
        Parameters:
        fieldName - name of field in body of POST-request
        uploadFile - a File to be uploaded
      • addBytesPart

        public void addBytesPart​(String fieldName,
                                 String fileName,
                                 byte[] bytes)
        Adds a upload file section to the request
        Parameters:
        fieldName - name of field in body of POST-request
        fileName - filename
        bytes - an array of bytes to be uploaded
      • finish

        public String 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.