cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload - determine size

Former Member
0 Kudos

Hi Gurus,

i use in this time the fileupload UI element - after choosing a file I developed a upload action with following code:

byte[] file = element.getStorage_place();

double kb = file.length * 0.0009765625;

if(kb > 5000){

...Message...

}else{

}

The problem, i cann't calculate the size after uploading the file, which takes many minutes if you choose a file with a size over 10 MB.

To avoid the timeout, i like to determine the size before uploading - is there any possibility?

Thanks in advance Stefan

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Vito,

the problem, the ui elements returns only the filename - how can i get the directory?

Thanks Stefan

Former Member
0 Kudos

Stefan,

please check the API regarding IWDResource:

https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/services/sal/datatransport/api/I...

Note that you can use getUrl to get the URL, so also the directory.

Regards,

Vito

Former Member
0 Kudos

Thanks,

but we use NW2004 - so i can find the IWDResource. Any other ideas?

Thanks Stefan

Former Member
0 Kudos

Hi Stefan

follow the blog Kanwalpreet indicated to you, that's cool. But if you want to ckeck the file size beforeupload use this code:

.....

f = new File(directory, filename); // Create a file object

in = new FileReader(f); // Create a char stream to read it

int size = (int) f.length(); // Check file size

if (......) //Here go ahead with your considerations regarding file size

.....

Thanks,

Vito

Former Member
0 Kudos

Hi Stefan..

Chk this links..

Hop this will helpful for u..

Urs GS

Former Member
0 Kudos