File upload with non-ascii name

I'm designing a system that includes file-uploads. My problem is that any non-ascii chars in the filename are encoded strangely when saved. ä is encoded to å etc.
I use Tomcat with the -Dfile.encoding="UTF-8" in the Catalina file. I get the same result despite method; my own implementation, apache commons or Javazoom's uploadBean. All the JSP charset parameters are set.
Any ideas?

Hi amitads,
I'm sure u've used Java enough. Also, u must have learned about the \ (backslash) escape character ?
So, if u want to include a string like a single quote, u can write \' and for a double quote u can write \".
Try this ... I'm sure it will help.
Keep me posted.
Cheers !!
Sherbir.

Similar Messages

  • How to send an attached file containing with non-ascii code ?

    Hi,
    I want to send a attaced text file containing with non-ascii code(Traditional Chinese). Is there any way to solve the encoding problem?
    Currently, it transfer into non-meaningful code in receiving side.
    Thanks for the help in advance.

    Here is the code:
    Session _gSession = null;
    MimeMessage message = null;
    Properties props = new Properties();
    props.put("mail.smtp.host", smtpHost);
    _gSession = javax.mail.Session.getInstance(props, null);
    message = new MimeMessage(_gSession);
    message.setFrom(new InternetAddress(emailSender , emailSender));
    InternetAddress ia[] = new InternetAddress[1];
    ia[0] = new InternetAddress(emailReceiver, emailReceiver);
    message.setRecipients(Message.RecipientType.TO, ia);
    message.setSubject("Test Encoding Attached File");
    message.saveChanges();
    BodyPart messageBodyPart = new MimeBodyPart();
    DataSource fds = new FileDataSource("Big5_Code.txt");
    messageBodyPart.setDataHandler(new DataHandler(fds));
    messageBodyPart.addHeader("Content-ID","meme");
    MimeMultipart multipart = new MimeMultipart("related");
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    transport.connect();
    transport.send(message);

  • Sending mail from servers with non-ASCII names

    As part of an effort to internationalize our product we're testing on machines with host names that include non-ASCII characters (accented e's and whatnot). When trying to send mail from these machines we're getting:
    javax.mail.MessagingException: 501 5.5.4 Invalid Address
    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1634)
    at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1068)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:458)
    at javax.mail.Service.connect(Service.java:291)
    at javax.mail.Service.connect(Service.java:172)
    at javax.mail.Service.connect(Service.java:121)
    at javax.mail.Transport.send0(Transport.java:190)
    at javax.mail.Transport.send(Transport.java:120)
    at msgsendsample.main(msgsendsample.java:86)
    Looking at a network trace I see the EHLO command being sent as
    EHLO test[0xe9][0xdf]\r\n
    where the machine name is testéß. From a Unicode table 0xe9 0xdf = é ß.
    I found a reference from RFC 5336 (SMTP Extension for Internationalized Email Addresses) that says the hostname in the EHLO must be in the form of ACE (ASCII-compatible encoding) labels:
    3.7.1. The Initial SMTP Exchange
    When an SMTP connection is opened, the server normally sends a
    "greeting" response consisting of the 220 response code and some
    information. The client then sends the EHLO command. Since the
    client cannot know whether the server supports UTF8SMTP until after
    it receives the response from EHLO, any domain names that appear in
    this dialogue, or in responses to EHLO, MUST be in the hostname form,
    i.e., internationalized ones MUST be in the form of ACE labels.
    ACE encoding for my machine would be: java.net.IDN.toASCII("test4éß") --> "xn--testss-eva".
    I'm not sure if this RFC applies in this case - I didn't know anything about the guts of SMTP until yesterday - but it makes sense that you'd need to escape the hostname in the EHLO until you can negotiate capabilities.
    Looking at the JavaMail API it seems that if I were to call SMTPTransport.helo(String domain) myself without going through the higher-level Transport class that maybe I could work around the issue, but I haven't looked into it enough to know if that's feasible.
    Is anyone familiar with this problem? I'm using JavaMail 1.4.2 on Windows 2003 and Exchange as my SMTP server.
    thanks,
    Eric

    Same problem here (or at least in part). Some .mac folders did no longer show any messages, while they were there and could be seen online and with Thunderbird. After your remark I changed the name of a folder which contained a "´" and now it works. It is really strange because there is another folder with a "¨" in it which does not work (I will test if the name change works with this folder as well in a minute) whilst there is another one with such name which works fine. The update really messed up Mail and in Dutch we just use such characters so Mail without supporting them will be rather useless for me...

  • Mail IMAP after 10.5.2 can't read ANY mails in boxes with non-ascii names

    I have Mail with IMAP that connects to a regular MAC OS X Tiger server running IMAP.
    After upgrading to 10.5.2 on the client, Mail can no longer read ANY mails at all in any mailbox whose path contains a non-ascii character!
    Hence: If a box is called 'Övrigt', it only lists the mails in the mail box, but it will not show any of the contents of any of the mails! Hence, I cannot access any of these mails! Catastrophic!
    I have to downgrade to 10.5.1, unless someone knows of a workaround.

    Same problem here (or at least in part). Some .mac folders did no longer show any messages, while they were there and could be seen online and with Thunderbird. After your remark I changed the name of a folder which contained a "´" and now it works. It is really strange because there is another folder with a "¨" in it which does not work (I will test if the name change works with this folder as well in a minute) whilst there is another one with such name which works fine. The update really messed up Mail and in Dutch we just use such characters so Mail without supporting them will be rather useless for me...

  • UploadedFile and filenames with non-ascii chars

    Hi
    I'm using an UploadedFile object in my web app, and all works fine. However, when I try to upload a file, with a filename containing non-ascii chars (e.g. Spanish), I see that the getBytes method returns an empty byte array, the filename is not stored correctly (the non-ascii chars are lost, replaced by another representation), and that the content-type is application/octet-stream instead of image/png as supposed to be.
    If I rename that same file to have only ascii chars - everything is back to normal.
    How can I upload files with non-ascii chars in their name?

    Hi, back! Spent a few hours experimenting and found
    that everything is working great (including the creation
    of international non-ASCII foldernames) when I used
    utf-8 encoding in the sieve filters rules for the
    the match strings and the folder names... at least
    so far so good... for your ref and sorry for bothering.

  • Filling clob with non ascii characters

    Hello,
    I have had some problems with clobs and usage of german
    umlauts (����). I was'nt able to insert or update
    strings containing umlaute in combination with string
    binding. After inserting or updating the umlaut
    characters were replaced by strange (spanish) '?'
    which were upside down.
    However, it was working when I did not use string bindung.
    I tried varios things, after some time I tracked
    the problem down to to oracle.toplink.queryframework.SQLCall.java. In the
    prepareStatement(...) you find something
    like
    ByteArrayInputStream inputStream = new ByteArrayInputStream(((String) parameter).getBytes());
    // Binding starts with a 1 not 0.
    statement.setAsciiStream(index + 1, inputStream,((String) parameter).getBytes().length);
    I replaced the usage of ByteArrayInputStram with CharArrayReader:
    // TH changed, 26.11.2003, Umlaut will not work with this.
    CharArrayReader reader = new CharArrayReader(((String) parameter).toCharArray());     
    statement.setCharacterStream(index + 1, reader, ((String) parameter).length() );
    and this worked.
    Is there any other way achieving this? Did anyone
    get clobs with non ascii characters to work?
    Regards -- Tobias
    (Toplink 9.0.3, Clob was mapped to String, Driver was Oracle OCI)

    I don't think the console font is the problem. I use Lat2-Terminus16 because I read the Beginner's Guide on the wiki while installing the system.
    My /etc/vconsole.conf:
    KEYMAP=de
    FONT=Lat2-Terminus16
    showconsolefont even shows me the characters missing in the file names; e.g.: Ö, Ä, Ü

  • Can't get the attachment filename out of a Part (with non ascii characters)

    Hello, all and happy new year :)
    My issue is with non ascii filename in attachments... Yes i've read the FAQ : http://www.oracle.com/technetwork/java/faq-135477.html#encodefilename
    I can't get the filename out of the BodyPart for those kind of attachments
    here's my unit test :
         * contains various parts from various mailer encoded in different ways...
         private enum EncodedFileNamePart{
              OUTLOOK("Content-Type: text/plain;\n name=\"=?iso-8859-1?Q?c'estd=E9j=E0no=EBl=E7ac'estcool.txt?=\" \nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename=\"=?iso-8859-1?Q?c'estd=E9j=E0no=EBl=E7ac'estcool.txt?=\" \n\nnoel 2010\n","c'estdéjànoëlçac'estcool.txt"),
              GMAIL("Content-Type: text/plain; charset=US-ASCII; name=\"=?ISO-8859-1?B?ZOlq4G5v62znYWNlc3Rjb29sLnR4dA==?=\"\nContent-Disposition: attachment; filename=\"=?ISO-8859-1?B?ZOlq4G5v62znYWNlc3Rjb29sLnR4dA==?=\"\nContent-Transfer-Encoding: base64\nX-Attachment-Id: f_giityr5r0\n\namluZ2xlIGJlbGxzIQo=\n","déjànoëlçacestcool.txt"),
              THUNDERBIRD("Content-Type: text/plain;\n name=\"=?ISO-8859-1?Q?d=E9j=E0no=EBl=E7acestcool=2Etxt?=\"\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename*0*=ISO-8859-1''%64%E9%6A%E0%6E%6F%EB%6C%E7%61%63%65%73%74%63%6F;\n filename*1*=%6F%6C%2E%74%78%74\n\njingle bells!\n","déjànoëlçacestcool.txt"),
              EVOLUTION("Content-Disposition: attachment; filename*=ISO-8859-1''d%E9j%E0no%EBl.txt\nContent-Type: text/plain; name*=ISO-8859-1''d%E9j%E0no%EBl.txt; charset=\"UTF-8\" \nContent-Transfer-Encoding: 7bit\n\njingle bells\n","déjànoël.txt"),
              String content=null;
              String target=null;
              private EncodedFileNamePart(String content,String target){
                   this.content=content;
                   this.target=target;
              public Part get(){
                   try{
                   ByteArrayInputStream bis = new ByteArrayInputStream(this.content.getBytes());
                   Part part = new MimeBodyPart(bis);
                   bis.close();
                   return part;
                   catch(Throwable e){
                        return null;
              public String getTarget(){
                   return this.target;
         @Test
         public void testJavamailDecode() throws MessagingException, UnsupportedEncodingException{
              System.setProperty("mail.mime.encodefilename", "true");
              System.setProperty("mail.mime.decodefilename", "true");
              for(EncodedFileNamePart part : EncodedFileNamePart.values())
                   assertEquals(part.name(),MimeUtility.decodeText(part.get().getFileName()),part.getTarget());     
    I take a NullPointerExcepion in the decodeText because getFileName() return null for the EVOLUTION case, and work well with OUTLOOK, THUNDERBIRD and GMAIL.
    Evolution's content type is "Content-Disposition: attachment; filename*=ISO-8859-1''d%E9j%E0no%EBl.txt" wich doesn't look like the other (looks like the RFC 2616 or RFC5987 to do it.)
    How can i handle this situation except by writting my own decoder?
    Thanks for your answers!
    Edited by: user13619058 on 4 janv. 2011 07:44

    Set the System property "mail.mime.decodeparameters" to "true" to enable the RFC 2231 support.
    See the javadocs for the javax.mail.internet package for the list of properties.
    Yes, the FAQ entry should contain those details as well.

  • Problems with non-ASCII characters on Linux Unit Test Import

    I found a problem with non-ASCII characters in the Unit Test Import for Linux.  This problem does not appear in the Unit Test Import for Windows.
    I have attached a Unit Test export called PROC1.XML  It tests a procedure that is included in another attachment called PROC1.txt. The unit test includes 2 implementations.  Both implementations pass non-ASCII characters to the procedure and return them unchanged.
    In Linux, the unit test import will change the non-ASCII characters in the XML file to xFFFD. If I copy/paste the the non-ASCII characters into the Unit Test after the import, they will be stored and executed correctly.
    Amazon Ubuntu 3.13.0-45-generic / lubuntu-core
    Oracle 11g Express Edition - AL32UTF8
    SQL*Developer 4.0.3.16 Build MAIN-16.84
    Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
    In Windows, the unit test will import the non-ASCII characters unchanged from the XML file.
    Windows 7 Home Premium, Service Pack 1
    Oracle 11g Express Edition - AL32UTF8
    SQL*Developer 4.0.3.16 Build MAIN-16.84
    Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
    If SQL*Developer is coded the same between Windows and Linux, The JVM must be causing the problem.

    Set the System property "mail.mime.decodeparameters" to "true" to enable the RFC 2231 support.
    See the javadocs for the javax.mail.internet package for the list of properties.
    Yes, the FAQ entry should contain those details as well.

  • File upload with 'asp vb' backend

    Hello,
    I am trying to get file uploading with flex (flash buider) working. There are plenty of examples with a php backend, but i need the script for a 'asp vb' backend.
    I' ve tried lots of different approaches but can't get it right. Someone out there with a solution?
    Thanx!!

    Believe it or not I have to do this also.
    I have legacy ASP code that uses ASPUpload that I'd like to get working with my Flash CS5 and FlashBuilder Burrito front-ends.
    it's just multipart encoded.
    So, if you first test it with ASPUpload and a simple form, trying just FILE1 first, and it works with ASP backend then tackle the FlashBuilder side with some debugging.
    ASPUpload is still an extremely embedded component on tens of thousands if not more sites, and it was just updated, but I think the previous version just before this update, the one that's out there in code on so many sites, that is what Flash needs to work with.
    ASPUpload is doing its part, as it follows all the multipart encoded RFC rules and has worked for years.
    I'd love to join you in finding out what's going on here.
    This is a long-standing issue.
    I've done PHP also.  But again, enhancing an interface with FlashBuilder4 or Burrito, to integrate with working legacy code makes it hard when something is not working on the Flash side (it appears anyway) as ASPUpload form posts are extremely easy.

  • Multiple File Upload With Metadata Using REST

    hi all
    I want to upload multiple files with metadata to document library using REST API. I am using this msdn article
    http://msdn.microsoft.com/en-us/library/office/dn769086(v=office.15).aspx for uploading file. I am able to upload single file to document library but it is not working for multiple file. when I select multiple file it is uploading last selected file. can
    anyone help with this. I am using office 365 environment.
    Thanks in advance

    Hi,
    According to your post, my understanding is that you wanted to use the REST to upload multiple files.
    Per my knowledge, the REST API is not supported for uploading multiple files via a single call.
    You can write your own loop to upload multiple files via an individual call.
    http://sharepoint.stackexchange.com/questions/108525/multiple-file-upload-with-metadata-using-rest/108532#108532
    More reference:
    http://sharepointfieldnotes.blogspot.com/2014/04/uploading-documents-and-setting.html
    http://www.shillier.com/archive/2013/03/26/uploading-files-in-sharepoint-2013-using-csom-and-rest.aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Problems with non-ascii keywords

    I have some problems with non-ascii keywords that makes the whole keyword feature useless for me. I don't know if I'm doing something wrong or if there something I'm missing completely.
    The problem is that when I enter something like "grön" iPhoto sometimes refuses me to type in "grön" on another photo and "eats" the "ö". And if I select the matching keyword from the popup list iPhoto has changed the originally "grön" to "gr¨ön" (if that comes out right on the web). Here are a few screenshots to show what happens
    If someone knows what happens I would really appriciate some hints on how to avoid this.
    Note that adding/editing keywords works just fine in Aperture.

    There is a long standing issue with iPhoto and non-ascii characters. I know of no solution.
    iPhoto menu -> Provide iPhoto Feedback and report it as a bug.
    Regards
    TD

  • File Uploading with two command button

    Hi all,
    After a long I return back.
    I am having a JSP page with some mandatory fields and one attach document field.
    I am using JSF framework so for file upload i used the tag <t:inputfileupload>, for compulsion fields I used the attribute required = true.
    My problem is,
    If i attach the file and click attach button before filling mandatory fields the action method is not called. Only after filling the mandatory fields the action method is called. What may be the reason for this?
    Is there any example for file uploading with in form and it has two separate command buttons?

    DHURAI wrote:
    Hi all,
    After a long I return back.
    I am having a JSP page with some mandatory fields and one attach document field.
    I am using JSF framework so for file upload i used the tag <t:inputfileupload>, for compulsion fields I used the attribute required = true.
    My problem is,
    If i attach the file and click attach button before filling mandatory fields the action method is not called. Only after filling the mandatory fields the action method is called. What may be the reason for this?My guess: you get validation errors, but you don't have a <h:messages/> in your JSF page so you don't see the error yourself. If you check your log files it will most likely be mentioned there.

  • Can anyone recommend a free file uploader with progress bar?

    Can anyone recommend a free file uploader with progress bar?
    I have searched google but with no luck.
    Ideally it would be a DW extension but that might be wishing
    for too much.
    I would like a large file limit for video and multiple file
    extensions allowed.
    Thanks in advance

    Heya,
    Check out this due Waleed he has some nice tuts and here's
    a
    link
    to file upload with progress bar tutorial he has. Granted it
    looks like it's just an animated gif letting users know their file
    is uploading; if you want realtime upload information displayed for
    the user you're gonna have to look at something like Flash with the
    power of actionscript to achieve that result.
    Hope that helps!

  • Problem with non-ASCII file name in content disposition header

    Hi All,
    I am facing some problems with the non-ASCII file name incase of content-disposition header. I read from the RFC 2183 that if the file name contains non-ASCII characters then the same should be encoded before sending to browser. I did the same but realized 2 problems:
    1. The name of the file is truncated in case the file name is slightly long for e.g. �����������j�b�g��������������������������.txt
    2. Also when the same file is opened in notepad, the title is showing encoded name %E6%9C%80%E4%B8%8A%E4%BD%8D.....
    Overall, I feel that the browser is not understanding or responding to the encoded header values.
    Is there any solution to this problem? I am using Microsoft IE 6.0.
    The code snippet is given below:
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              String fileName = "�����������j�b�g��������������������������.txt";          
              fileName = URLEncoder.encode(fileName, "UTF-8");
              resp.setCharacterEncoding("UTF-8");
              resp.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
              resp.setContentType("application/download-binary");
              String s = "This is inside txt file";
              resp.getOutputStream().write(s.getBytes("UTF-8"));
              return;
         }Any help or pointer would be highly appreciated.
    Thanks and Regards,
    Ashish

    The MIME standards for non-ASCII filenames are not widely implemented.
    Many mailers use an ad hoc method for encoding filenames. JavaMail
    supports both methods, but you need to set properties, such as the
    mail.mime.encodefilename property. See the JavaMail javadocs for
    the javax.mail.internet package.

  • JavaMail with non-ascii file name attachment.

    Hello,
    I add a file to the mail, which file name is a Chinese name. After I sent it and receive in other email client (M$outlook), it could not display the correct file name for the attachment file.
    How can solve this ?

    The MIME standards for non-ASCII filenames are not widely implemented.
    Many mailers use an ad hoc method for encoding filenames. JavaMail
    supports both methods, but you need to set properties, such as the
    mail.mime.encodefilename property. See the JavaMail javadocs for
    the javax.mail.internet package.

Maybe you are looking for

  • Looking for Accessible PDF creator

    (I'm posting this on behalf of my employer. I looked through terms of service and this sort of posting doesn't appear to be discouraged. If it is, let me know and I'll remove. Thanks!) Pacific Educational Press is seeking people with advanced knowled

  • Reloading precompiled JSP

    Hi, We are trying to do this: - precompile foo.jsp to foo.class offline; - copy foo.class and foo.jsp into a machine weblogic is running, maintain their timestamp when they are compiled and generated; - when accessing foo.jsp, we hope weblogic will l

  • Iptables configuration won't stick

    I followed wiki and configured iptables firewall like this: iptables-restore < /etc/iptables/empty.rules iptables -N TCP iptables -N UDP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT iptables -P INPUT DROP iptables -A INPUT -m conntrack --ctstat

  • Icloud control panel sync to chrome does not work

    Bookmark sync does not work. - Installed icloud control 3.0. - installed extension for Chrome "iCloud Bookmarks" I get the message "icloud Bookmarks extension for Chrome is required". Keep pressing the button enable but nothing happens. Please help !

  • New book size in Aperture?

    I notice iPhoto now makes a larger format book. Does the new update for Aperture give us a new book size also?