HTTP Client data container for form(multipart/form-data)
Dependencies: mbed EthernetInterface HTTPClient mbed-rtos
file_upload.cpp
- Committer:
- va009039
- Date:
- 2012-05-31
- Revision:
- 0:fcd577a3925b
- Child:
- 1:77c616a1ab54
File content as of revision 0:fcd577a3925b:
#include "mbed.h" #include "EthernetNetIf.h" #include "HTTPClient.h" #include "HTTPPoster.h" LocalFileSystem local("local"); Serial pc(USBTX, USBRX); EthernetNetIf eth; int main() { pc.baud(921600); int ethErr = eth.setup(); if(ethErr) {printf("Error %d in setup.\n", ethErr); exit(1);} HTTPClient client; HTTPPoster data; data.addFile("image", "/local/image.jpg"); data.add("title", "hello"); string url = "http://va009039.appspot.com/mbed/upload/"; HTTPResult r = client.post(url.c_str(), data, NULL); printf("result:%d HTTPResponseCode: %d\n", r, client.getHTTPResponseCode()); exit(1); }