You will need to add Exception
handling and deal with the InputStream
and potentially clean up of temp files (see DiskFileItemFactory
docs) but the basics are as follows, when using the org.restlet.ext.fileupload library.
@Put
public void handleUpload(Representation entity) {
List<FileItem> items = new RestletFileUpload(new DiskFileItemFactory())
.parseRepresentation(representation);
for (FileItem item : items) {
if (!item.isFormField()) {
MediaType type = MediaType.valueOf(item.getContentType());
InputStream inputStream = item.getInputStream();
}
}
}
for a gae Solution try replacing the DiskFileItemFactory
with a gwtupload.server.MemoryFileItemFactory
.