Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » the supposed uploaded file doesn't exist on disk after successful upload process
the supposed uploaded file doesn't exist on disk after successful upload process [message #118456] Wed, 14 January 2009 16:16 Go to next message
New Yop Javeloper is currently offline New Yop JaveloperFriend
Messages: 8
Registered: July 2009
Junior Member
Hi everyone!

I've downloaded the file upload widget's last update.

Everything compile un run fine except that for:

============================================================
private class FileUploadAdapter extends UploadAdapter {

@Override
public void uploadFinished(final UploadEvent event) {

if (event.isFinished()) {
UploadDialog.this.uploadedFile = new
File(UploadDialog.this.upload.getLastFileUploaded());
UploadDialog.this.filePath = UploadDialog.this.uploadedFile.getName();

UploadDialog.this.uploadInfo = "File sucessfully uploaded!\r\n" +
"Absolute Path: " + UploadDialog.this.uploadedFile.getAbsoluteFile() +
"\r\n" +
"Name: " + UploadDialog.this.filePath + "\r\n" +
"Total File size: " + event.getUploadedTotal() + "\r\n" +
"Parcial size: " + event.getUploadedParcial() + "\r\n" +
(UploadDialog.this.uploadedFile.exists() ? "File exist on disk" :
"Sorry, the file doesn't exist at " +
UploadDialog.this.uploadedFile.getAbsoluteFile()) + "\r\n";

} else {
UploadDialog.this.uploadInfo = "File couldn't be uploaded yet";
}
UploadDialog.this.performFinish();
}
}
============================================================

this UploadDialog logs on my console:

============================================================
14 janv. 2009 17:12:13 xxx.yyy.zzz.ui.util.dialog.UploadDialog
performFinish
INFO: File sucessfully uploaded!
Absolute Path: C:\Program Files\eclipse\aFileThatDoesNotExist.zip
Name: aFileThatDoesNotExist.zip
Total File size: 41973071
Parcial size: 36315704
Sorry, the file doesn't exist at C:\Program
Files\eclipse\aFileThatDoesNotExist.zip
============================================================

What's the problem? and the ...solution if exist! ;)
I'm running my application in eclipse hosted mode.
Thank U!
Re: the supposed uploaded file doesn't exist on disk after successful upload process [message #118461 is a reply to message #118456] Thu, 15 January 2009 08:07 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi,

the uploaded file isn't necessarily stored on the disk but also could be
stored in memory only (this is handled by Apache commons fileupload). To
access the file you can use
Upload#getUploadItem()#getFileInputStream().

Hope that helps,
Stefan.

New Yop Javeloper schrieb:
> Hi everyone!
>
> I've downloaded the file upload widget's last update.
>
> Everything compile un run fine except that for:
>
> ============================================================
> private class FileUploadAdapter extends UploadAdapter {
>
> @Override
> public void uploadFinished(final UploadEvent event) {
>
> if (event.isFinished()) {
> UploadDialog.this.uploadedFile = new
> File(UploadDialog.this.upload.getLastFileUploaded());
> UploadDialog.this.filePath =
> UploadDialog.this.uploadedFile.getName();
>
> UploadDialog.this.uploadInfo = "File sucessfully
> uploaded!\r\n" +
> "Absolute Path: " +
> UploadDialog.this.uploadedFile.getAbsoluteFile() + "\r\n" +
> "Name: " + UploadDialog.this.filePath + "\r\n" +
> "Total File size: " + event.getUploadedTotal() + "\r\n" +
> "Parcial size: " + event.getUploadedParcial() + "\r\n" +
> (UploadDialog.this.uploadedFile.exists() ? "File exist on
> disk" : "Sorry, the file doesn't exist at " +
> UploadDialog.this.uploadedFile.getAbsoluteFile()) + "\r\n";
>
> } else {
> UploadDialog.this.uploadInfo = "File couldn't be uploaded yet";
> }
> UploadDialog.this.performFinish();
> }
> }
> ============================================================
>
> this UploadDialog logs on my console:
>
> ============================================================
> 14 janv. 2009 17:12:13 xxx.yyy.zzz.ui.util.dialog.UploadDialog
> performFinish
> INFO: File sucessfully uploaded!
> Absolute Path: C:\Program Files\eclipse\aFileThatDoesNotExist.zip
> Name: aFileThatDoesNotExist.zip
> Total File size: 41973071
> Parcial size: 36315704
> Sorry, the file doesn't exist at C:\Program
> Files\eclipse\aFileThatDoesNotExist.zip
> ============================================================
>
> What's the problem? and the ...solution if exist! ;)
> I'm running my application in eclipse hosted mode.
> Thank U!
>
Re: the supposed uploaded file doesn't exist on disk after successful upload process [message #118496 is a reply to message #118461] Thu, 15 January 2009 12:46 Go to previous message
New Yop Javeloper is currently offline New Yop JaveloperFriend
Messages: 8
Registered: July 2009
Junior Member
Hi!
Right!
It works fine!

Here is the code:

============================================================ =====================
private class FileUploadAdapter extends UploadAdapter {

@Override
public void uploadFinished(final UploadEvent event) {

if (event.isFinished()) {
final InputStream inputStream =
UploadDialog.this.upload.getUploadItem().getFileInputStream( );
final File temp = new File(System.getProperty("java.io.tmpdir") +
RWT.getSessionStore().getId() + new Random().nextLong());
temp.deleteOnExit();
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(temp);
} catch (final FileNotFoundException e) {
}
final byte[] buffer = new byte[1024];
int length;
try {
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
} catch (final IOException e) {
}
try {
inputStream.close();
outputStream.close();
} catch (final IOException e) {
}

UploadDialog.this.uploadedFile = temp;
} else {
}
UploadDialog.this.performFinish();
}
}
============================================================ =====================

Thank You All! ;)
Previous Topic:RAP integration into WebSphere Portal
Next Topic:New RWT graphic widget GCCanvas
Goto Forum:
  


Current Time: Wed Feb 01 13:49:01 GMT 2023

Powered by FUDForum. Page generated in 0.06598 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top