MHTTPFilePoster Library

Along with my MVideoCapture and MVideoPlayback libraries, I needed to develop a means to post those files to the web through standard HTTP. For this reason, I put together this library.

You can download the library and source.

Here is an example which also uses the MVideoCapture library:

import processing.core.*;

import com.mobvcasting.mhttpfileposter.*;
import com.mobvcasting.mvideocapture.*;

public class MHTTPFilePosterTest extends PMIDlet
MVideoCapture vidcap;
MHTTPFilePoster poster;

String captureKey = "Capture Video";
String stopKey = "Stop Capture";
String uploadKey = "Upload Video";
String uploadStatus = "Check Upload";

String statusMessage = "Not Captured";

byte[] outputArray;

PFont font;

public void setup()
vidcap = new MVideoCapture(this);

font = loadFont("ArialMT-12.mvlw");

public void draw()

public void softkeyPressed(String label)
if (label.equals(captureKey))
else if (label.equals(stopKey))
outputArray = vidcap.getCapturedVideo();
//outputArray = new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff};
else if (label.equals(uploadKey))
poster = new MHTTPFilePoster(this, "http://your.server/upload.php", "avideofile", "bytes", outputArray);
statusMessage = "Uploading Video";
else if (label.equals(uploadStatus))
statusMessage = poster.getStatus() + " " + poster.getServerResponse();

public void libraryEvent(Object library, int event, Object data)


Here is the PHP that this posts to (PHP is not required, any language can be used to receive the standard HTTP file upload that comes from the example):

You can find more examples and a discussion on using this library from my course Mobile Media Week 7 notes

Join the Conversation


  1. Great Notes from Lucas Cacela:

    i’m new to Processing and Mobile Processing and i found out very hard to find stuff related to Mobile Processing over the internet, so i tried to put together some notes and write a few lines about the MHTTPFilePoster library, a kind of reference, maybe it helps someone that is passing trought the same i passed, if you like it and think it can be usefull to someone, you can use it (maybe link to it or post it in the library page), feel free to correct any mistakes i made. Once again, thank you for your library, it was very helpfull to me.

    Here it goes: (i tried to explain in order what you need to have in your sketch to use the library)

    import com.mobvcasting.mhttpfileposter.*;

    Imports the library into the sketch.

    MHTTPFilePoster poster;

    Declares the element “poster” as a MHTTPFilePoster type where “poster” could be any valid variable.

    String[ ][ ] formvars = new String[4][2];
    formvars[0][0] = “subject”;
    formvars[0][1] = “the subject”;
    formvars[1][0] = “message_text”;
    formvars[1][1] = “the message”;
    formvars[2][0] = “form_submitted”;
    formvars[2][1] = “true”;
    formvars[3][0] = “submit”;
    formvars[3][1] = “submit”;

    A two dimensional array of form variables that need to be posted along with the file upload to make the form that the file is going to function correctly.

    poster = new MHTTPFilePoster(midlet, url, filename, form’s input element, byte[ ] var, formvars);

    Assigns the information required to file uploading to the “poster”.
    midlet: the sketch that will upload the file, generally use “this”.
    url: url of the form that will receive the file (example at
    filename: name of the file that is beeing uploaded, include the extension (example: “image.jpg”)
    form’s input element: the name of the form’s element that will receive the file (example: “bytes” in the form at
    byte[ ] var: the name of the byte[] type var that contais the data that will be uploaded as a file.
    formvars: the vars explained above.


    Uploads the file as declaired above.


    Returns an integer with the status of the file upload where:
    0: Not Started.
    1: Started.
    2: Complete.
    3: Error during upload.


    Returns a string with the server response to your upload.

  2. Muchas gracias por la explicación de los métodos y en general a los que han desarrollado esta librería! sin la comunidad no seriamos nada

Leave a comment

Your email address will not be published. Required fields are marked *