-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have tried to upload files with size less than 17 KB, but it is not working. Could you know inform me if exists any configuration to be done to upload files with size less than 17kb?
Thanks!!!!!!!
Hi alexandrecoelho,
Here is a demo without any other configuration: http://www.zkoss.org/zkdemo/file_handling/file_upload
Can you show us your code and configuration?
Hi, thanks!!
The upload it´s working, but when i create a file with the uploaded media, the size of file is 0KB. That just happened with files less than 17KB.
The part of code is:
Media media = ((UploadEvent)event).getMedia(); String path = Executions.getCurrent().getDesktop().getWebApp().getRealPath("/arquivos") + "\\"; try { if (media.isBinary()) { File dest = new File(path + media.getName()); Files.copy(dest, media.getStreamData()); } else { BufferedWriter writer = new BufferedWriter(new FileWriter(path + media.getName())); Files.copy(writer, media.getReaderData()); } } catch (IOException e) { e.printStackTrace(); }
Hi,
you have to check if the media is present in memory when creating the appropriate input stream / reader. Here's an example:
InputStream stream = new BufferedInputStream(media.inMemory() ? new ByteArrayInputStream(media.getByteData()) : media.getStreamData()); ... Reader reader = new BufferedReader(media.inMemory() ? new StringReader(media.getStringData()) : media.getReaderData());
Cheers, Maik
Asked: 2012-02-03 17:42:01 +0800
Seen: 189 times
Last updated: Feb 09 '12