Public Member Functions | Private Attributes | Static Private Attributes | List of all members
com.introlab.rtabmap.MultipartUtility Class Reference

Public Member Functions

void addFilePart (String fieldName, File uploadFile) throws IOException
 
void addFormField (String name, String value)
 
void addHeaderField (String name, String value)
 
List< String > finish () throws IOException
 
 MultipartUtility (String requestURL, String token, String charset) throws IOException
 

Private Attributes

final String boundary
 
String charset
 
HttpURLConnection httpConn
 
OutputStream outputStream
 
PrintWriter writer
 

Static Private Attributes

static final String LINE_FEED = "\r\n"
 

Detailed Description

This utility class provides an abstraction layer for sending multipart HTTP POST requests to a web server.

Author
www.codejava.net http://www.codejava.net/java-se/networking/upload-files-by-sending-multipart-request-programmatically

Definition at line 25 of file MultipartUtility.java.

Constructor & Destructor Documentation

◆ MultipartUtility()

com.introlab.rtabmap.MultipartUtility.MultipartUtility ( String  requestURL,
String  token,
String  charset 
) throws IOException
inline

This constructor initializes a new HTTP POST request with content type is set to multipart/form-data

Parameters
requestURL
charset
Exceptions
IOException

Definition at line 40 of file MultipartUtility.java.

Member Function Documentation

◆ addFilePart()

void com.introlab.rtabmap.MultipartUtility.addFilePart ( String  fieldName,
File  uploadFile 
) throws IOException
inline

Adds a upload file section to the request

Parameters
fieldNamename attribute in <input type="file" name="..." >
uploadFilea File to be uploaded
Exceptions
IOException

Definition at line 79 of file MultipartUtility.java.

◆ addFormField()

void com.introlab.rtabmap.MultipartUtility.addFormField ( String  name,
String  value 
)
inline

Adds a form field to the request

Parameters
namefield name
valuefield value

Definition at line 64 of file MultipartUtility.java.

◆ addHeaderField()

void com.introlab.rtabmap.MultipartUtility.addHeaderField ( String  name,
String  value 
)
inline

Adds a header field to the request.

Parameters
name- name of the header field
value- value of the header field

Definition at line 113 of file MultipartUtility.java.

◆ finish()

List<String> com.introlab.rtabmap.MultipartUtility.finish ( ) throws IOException
inline

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.
Exceptions
IOException

Definition at line 124 of file MultipartUtility.java.

Member Data Documentation

◆ boundary

final String com.introlab.rtabmap.MultipartUtility.boundary
private

Definition at line 26 of file MultipartUtility.java.

◆ charset

String com.introlab.rtabmap.MultipartUtility.charset
private

Definition at line 29 of file MultipartUtility.java.

◆ httpConn

HttpURLConnection com.introlab.rtabmap.MultipartUtility.httpConn
private

Definition at line 28 of file MultipartUtility.java.

◆ LINE_FEED

final String com.introlab.rtabmap.MultipartUtility.LINE_FEED = "\r\n"
staticprivate

Definition at line 27 of file MultipartUtility.java.

◆ outputStream

OutputStream com.introlab.rtabmap.MultipartUtility.outputStream
private

Definition at line 30 of file MultipartUtility.java.

◆ writer

PrintWriter com.introlab.rtabmap.MultipartUtility.writer
private

Definition at line 31 of file MultipartUtility.java.


The documentation for this class was generated from the following file:


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:26