Mam server postawiony na jetty. Z aplikajci android wysyłam zdjecie w taki sposób:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_PHOTO_FOR_AVATAR && resultCode == Activity.RESULT_OK) {
if (data == null) {
return;
}
String path = getPath(data.getData());
//Uploading code
try {
//Creating a multi part request
new MultipartUploadRequest(this, UUID.randomUUID().toString(), HttpRequestUtils.getUrlForEventImageUpload())
.addFileToUpload(path, "image") //Adding file
.addParameter("name", "jakies zdjecie") //Adding text parameter to the request
.setNotificationConfig(new UploadNotificationConfig())
.setMaxRetries(2)
.startUpload(); //Starting the upload
} catch (Exception exc) {
Toast.makeText(this, exc.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
Jak je odebrać po stronie servletu?
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("cos przyszlo!!");
}