I've got a form that allows a user to upload up to five images to an
action. Generally it all works fine. In the action, I iterate over
the List<FileBean> and make my own copy of each file.
private List<FileBean> files;
public List<FileBean> getFiles() { return files; }
public void setFiles(final List<FileBean> files) { this.files = files; }
private List<FileWithName> getStableFiles() {
try {
return new ArrayList() {{
for (FileBean fb : getFiles()) {
if (fb == null) continue;
final File file =
File.createTempFile("receipt", ".tmp");
fb.save(file);
add(new FileWithName(file,
fb.getFileName()));
}
}};
}
catch (IOException ioe) {
for (FileBean fb : getFiles()) try { fb.delete(); }
catch(IOException pointless) {}
throw new RuntimeException("Error handling uploaded
receipts", ioe);
}
}
I'm noticing however that things go wrong when an upload includes two
files (each in a different client machine directory) with the same
name. When that happens, I get this exception from inside the
FileBean:
Caused by: java.io.IOException: Some time between uploading and saving
we lost the file
/tmp/Jetty_0_0_0_0_38080_t.war__t__.p7dy5c/newlogo.png - where did it
go?.
at net.sourceforge.stripes.action.FileBean.save(FileBean.java:155)
at
tango.ui.action.account_holder.receipts.Upload$1.<init>(Upload.java:48)
at
tango.ui.action.account_holder.receipts.Upload.getStableFiles(Upload.java:44)
In this case, I had /tmp/newlogo.png and /home/m5/tmp/newlogo.png in
the upload list.
I'm still on 1.5.1 btw. Or is it 1.5? It's whatever wasn't released recently.
--
Turtle, turtle, on the ground,
Pink and shiny, turn around.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users