0

Fileupload component issues

asked 2007-09-12 07:19:13 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4513909

By: bosbert

Hi all,

I'm implementing a portlet that will be used to upload text files from clients.
These files are encoded in a french window's based encoding with some special characters (eg: e a e ...).
These files are respecting a predefined format and I need to keep them strictly unchanged.
I'm using th Fileupload component to get these files to the server. This component returns me an array of Media objects.
Unfortunately, I really don't have the hand on these components and I'm not able to specify the encoding, which is, I think, defined by default as UTF-8.
Because of this, I'm facing a lot of issues like lost of information when trying to convert these files.

Does anybody have an idea on how could I turn around this ?

Thanks a lot

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2007-09-12 10:39:24 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4514180

By: waterbottle

Hi,
ZK will transfer upload file to Reader or String automatically if uploaded file's content type start with 'text/'..
After upload, you can access text by getReaderData( if Media.inMemory() if false) or getStringData( if Media.inMemory() is true).
You can set default upload character in zk.xml like below:
<zk>
<system-config>
<upload-charset>YOUR ENCODING</upload-charset> </system-config> </zk>

the default value is UTF-8

/Dennis

link publish delete flag offensive edit

answered 2011-05-16 02:52:17 +0800

saprudin2009 gravatar image saprudin2009
30

I try your advise,

if(media.getContentType().startsWith("text/")){
if (media.inMemory()){
Files.copy(new File(path), media.getReaderData(), media.getStringData()); ---> UnsupportedEncodingException
}else{
BufferedWriter writer = new BufferedWriter(new java.io.FileWriter(
path));
Files.copy(writer, media.getReaderData());
}

}

But, its still error

java.io.UnsupportedEncodingException:
at sun.nio.cs.StreamEncoder.forOutputStreamWriter(StreamEncoder.java:42)

at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:83)
at org.zkoss.io.FileWriter.<init>(FileWriter.java:78)
at org.zkoss.io.Files.copy(Files.java:165)
at com.telkomsel.composer.TicketComposer.saveToDisk(TicketComposer.java:
287)
at com.telkomsel.composer.TicketComposer.onClick$btnUpload(TicketCompose
r.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.zkoss.zk.ui.event.GenericEventListener.onEvent(GenericEventListen
er.java:89)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:197)

at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:141)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessi
ngThreadImpl.java:493)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.sendEvent(EventProcess
ingThreadImpl.java:123)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:293)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:303)
at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractCom
ponent.java:2308)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:197)

at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:141)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessi
ngThreadImpl.java:493)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThr
eadImpl.java:425)

Please..., any advise...??

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: 2007-09-12 07:19:13 +0800

Seen: 568 times

Last updated: May 16 '11

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