in un'applicazione Web gwt. Devo inviare un file e alcuni parametri ad esso allegati.
su ServerSide
try {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iterator = upload.getItemIterator(request);
while (iterator.hasNext()) {
FileItemStream item = iterator.next();
if (item.isFormField()) {
String fieldName=item.getFieldName();
String fieldValue = Streams.asString(item.openStream());
System.out.println(" chk " +fieldName +" = "+ fieldValue);
} else {
stream = item.openStream();
fileName = item.getName();
mimetype = item.getContentType();
int c;
while ((c = stream.read()) != -1) {
System.out.print((char) c);
}
}
}
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println("out of try");
ByteArrayOutputStream output = new ByteArrayOutputStream();
int nRead;
while ((nRead = stream.read(buffer, 0, buffer.length)) != -1) {
System.out.println("lenth111" +nRead);
output.write(buffer, 0, nRead);
}
System.out.println("lenth" +nRead);
output.flush();
con questo codice posso leggere il flusso. e anche su console "fuori provare" è stampato anche
E infine sulla while ((nRead = stream.read(buffer, 0, buffer.length)) != -1)
linea ho ottenuto un avvertimento
ATTENZIONE:/UploadFileServlet: org.apache.commons.fileupload.FileItemStream $ ItemSkippedException.
Come risolvere questo problema. ??
Hi GameBuilder e Thomas Broyer, Hai trovato una soluzione su questo? Perché ho avuto lo stesso problema per giorni. Per favore, qualcuno potrebbe aiutarci? Grazie – Aerox
hey, anche io sto cercando lo stesso. Hai trovato qualche soluzione? –