0

Upload file with size less than 17 KB not working

asked 2012-02-03 17:42:01 +0800

alexandrecoelho gravatar image alexandrecoelho
21

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!!!!!!!

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2012-02-04 03:45:25 +0800

matthewgo gravatar image matthewgo
375

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?

link publish delete flag offensive edit

answered 2012-02-06 19:49:24 +0800

alexandrecoelho gravatar image alexandrecoelho
21

updated 2012-02-06 19:50:00 +0800

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();
		}

link publish delete flag offensive edit

answered 2012-02-09 09:18:59 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-02-03 17:42:01 +0800

Seen: 189 times

Last updated: Feb 09 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More