File upload in FormDataMultiPart with invalid Chinese filename in MS Window

Hi,
I found a strange problem that for the same file loading code work very well in OSX but not in Windows. The chinese filename get corrupted in Windows but not in OSX. I'm using Jersey 1.9 and the server is running Node.js. Is it a Java problem or Jersey?
here is my code:
FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new FileDataBodyPart("thumbnail", file));
System.out.println("******************** =" + file.getName());
System.out.println("form.getContentDisposition().getFileName() ="
+ form.getBodyParts().get(0).getContentDisposition()
.getFileName());
String s = clientResource.path("uploadTagFile").path(tagid)
.type(MediaType.MULTIPART_FORM_DATA_TYPE)
.accept(MediaType.APPLICATION_JSON).post(String.class, form);
try {
JSONObject j = (JSONObject) new JSONArray(s).get(0);
System.out.println("******************** =" + j.toString());
return j;
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
and the log returned from OSX:
Keep-Alive-Timer, called close()
Keep-Alive-Timer, called closeInternal(true)
Keep-Alive-Timer, SEND TLSv1 ALERT: warning, description = close_notify
Keep-Alive-Timer, WRITE: TLSv1 Alert, length = 22
Keep-Alive-Timer, called closeSocket(selfInitiated)
******************** =人题啊.png
form.getContentDisposition().getFileName() =人题啊.png
Allow unsafe renegotiation: false
Allow legacy hello messages: true
upload onSent: delta: 8192 bytes: 16589 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 3429 bytes: 20018 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 43 bytes: 20061 WebUploadFile.this.totalBytes: 19813
Sep 28, 2012 8:36:13 AM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client out-bound request
1 > POST https://192.168.56.101:8000/itags/uploadTagFile/1036
1 > Content-Type: multipart/form-data
1 > Accept: application/json
--Boundary_1_1298626937_1348792573616
Content-Type: image/png
Content-Disposition: form-data; filename="人题啊.png"; modification-date="Sat, 09 Jun 2012 14:30:06 GMT"; size=19813; name="thumbnail"
?PNG
IHDRY'??L?iCCPICC Profilex?T?k?P??e???:g     >h?ndStC??kW??Z?6?!H??m\??$?~?ًo:?w?>?كo{?
……….Jq ? ??
?8@@Y.?R$ ? @??@@\ d??J? ? ?!?c@pA???*E"? ??,?@@?B??? ??8@@Y.?R$ ? @??@@\ d??J? ? ?!?c@pA???*E"? ??,?@@?B??? ??8@@Y.?R$ ? @??@@\ d??J? ? ?!?c@pA???*E"? ??,?@@?B??? ???NA???8IEND?B`?
--Boundary_1_1298626937_1348792573616--
Thread-12, WRITE: TLSv1 Application Data, length = 333
Thread-12, WRITE: TLSv1 Application Data, length = 16404
Thread-12, WRITE: TLSv1 Application Data, length = 3697
Thread-12, READ: TLSv1 Application Data, length = 645
upload onReceiveStart: -1
download onReceived: delta: 334 bytes: 334
download onFinish
Sep 28, 2012 8:36:13 AM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client in-bound response
1 < 200
1 < content-type: application/json
1 < Transfer-Encoding: chunked
1 < Set-Cookie: connect.sid=BS4OPYlxBXYxHFIrad8q3cSj.x5iTP%2Fm7UMNc8oR7CUisHwjVLSFN4dZprbkWlha5AQk; path=/; expires=Fri, 28 Sep 2012 04:36:18 GMT; httpOnly
1 < Connection: keep-alive
1 < X-Powered-By: Express
1 <
[{"_id":"5064f1023785e3d91800000d","filename":"人题啊.png","contentType":"image/png","length":19813,"chunkSize":262144,"uploadDate":"2012-09-28T00:36:18.578Z","metadata":{"author":"6001011","status":"temp","lastModifiedDate":"2012-09-28T00:36:18.545Z"},"md5":"4ef5aad2a4a13b6e4729cc8456053af9","Server":"localhost","DB":"7001000"}]
******************** ={"_id":"5064f1023785e3d91800000d","chunkSize":262144,"md5":"4ef5aad2a4a13b6e4729cc8456053af9","length":19813,"DB":"7001000","filename":"人题啊.png","contentType":"image/png","uploadDate":"2012-09-28T00:36:18.578Z","Server":"localhost","metadata":{"author":"6001011","status":"temp","lastModifiedDate":"2012-09-28T00:36:18.545Z"}}
Sep 28, 2012 8:36:17 AM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 5 * Client out-bound request
5 > GET https://192.168.56.101:8000/itags/Tag/1036/editTag?jsonfile=%7B%22_id%22:%225064f1023785e3d91800000d%22,%22chunkSize%22:262144,%22md5%22:%224ef5aad2a4a13b6e4729cc8456053af9%22,%22length%22:19813,%22DB%22:%227001000%22,%22filename%22:%22%E4%BA%BA%E9%A2%98%E5%95%8A.png%22,%22contentType%22:%22image/png%22,%22uploadDate%22:%222012-09-28T00:36:18.578Z%22,%22Server%22:%22localhost%22,%22metadata%22:%7B%22author%22:%226001011%22,%22status%22:%22temp%22,%22lastModifiedDate%22:%222012-09-28T00:36:18.545Z%22%7D%7D
https://192.168.56.101:8000/itags/Tag/1036/editTag?jsonfile=%7B%22_id%22:%225064f1023785e3d91800000d%22,%22chunkSize%22:262144,%22md5%22:%224ef5aad2a4a13b6e4729cc8456053af9%22,%22length%22:19813,%22DB%22:%227001000%22,%22filename%22:%22%E4%BA%BA%E9%A2%98%E5%95%8A.png%22,%22contentType%22:%22image/png%22,%22uploadDate%22:%222012-09-28T00:36:18.578Z%22,%22Server%22:%22localhost%22,%22metadata%22:%7B%22author%22:%226001011%22,%22status%22:%22temp%22,%22lastModifiedDate%22:%222012-09-28T00:36:18.545Z%22%7D%7D
Thread-13, WRITE: TLSv1 Application Data, length = 703
Thread-13, READ: TLSv1 Application Data, length = 346
onReceiveStart: 10299
Thread-13, READ: TLSv1 Application Data, length = 10319
onReceived: delta: 8192 bytes: 8192
onReceived: delta: 2107 bytes: 10299
onFinish
But in windows:
Keep-Alive-Timer, called close()
Keep-Alive-Timer, called closeInternal(true)
Keep-Alive-Timer, SEND TLSv1 ALERT: warning, description = close_notify
Keep-Alive-Timer, WRITE: TLSv1 Alert, length = 32
Keep-Alive-Timer, called closeSocket(selfInitiated)
******************** =人题啊.png
form.getContentDisposition().getFileName() =人题啊.png
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
verify_data: { 242, 196, 62, 100, 237, 149, 2, 108, 226, 169, 30, 239 }
%% Cached client session: [Session-3, TLS_RSA_WITH_AES_128_CBC_SHA]
upload onSent: delta: 200 bytes: 200 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 8192 bytes: 8392 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 8192 bytes: 16584 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 3429 bytes: 20013 WebUploadFile.this.totalBytes: 19813
upload onSent: delta: 41 bytes: 20054 WebUploadFile.this.totalBytes: 19813
九月 28, 2012 8:29:21 上午 com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client out-bound request
1 > POST https://192.168.56.101:8000/itags/uploadTagFile/1036
1 > Content-Type: multipart/form-data
1 > Accept: application/json
--Boundary_1_14995509_1348792161365
Content-Type: image/png
Content-Disposition: form-data; filename="人题啊.png"; modification-date="Sat, 09 Jun 2012 14:30:06 GMT"; size=19813; name="thumbnail"
塒NG
--Boundary_1_14995509_1348792161365--
Thread-10, WRITE: TLSv1 Application Data, length = 3696
Thread-10, READ: TLSv1 Application Data, length = 32
Thread-10, READ: TLSv1 Application Data, length = 656
九月 28, 2012 8:29:21 上午 com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client in-bound response
1 < 200
1 < content-type: application/json
1 < Transfer-Encoding: chunked
1 < Set-Cookie: connect.sid=qbUD2aJkbJB6VoS79xm0sN7d.oFnD5R%2BOMiXsX8Iv%2Fp8ItHb10aYc6M4Aom09WFsRdz4; path=/; expires=Fri, 28 Sep 2012 04:29:26 GMT; h
ttpOnly
1 < Connection: keep-alive
1 < X-Powered-By: Express
1 <
[{"_id":"5064ef663785e3d918000009","filename":"锟斤拷锟解啊.png","contentType":"image/png","length":19813,"chunkSize":262144,"uploadDate":"2012-09-28T
00:29:26.397Z","metadata":{"author":"6001011","status":"temp","lastModifiedDate":"2012-09-28T00:29:26.366Z"},"md5":"4ef5aad2a4a13b6e4729cc8456053af9",
"Server":"localhost","DB":"7001000"}]
upload onReceiveStart: -1
download onReceived: delta: 337 bytes: 337
download onFinish
******************** ={"_id":"5064ef663785e3d918000009","chunkSize":262144,"md5":"4ef5aad2a4a13b6e4729cc8456053af9","length":19813,"DB":"7001000","fil
ename":"????.png","contentType":"image/png","uploadDate":"2012-09-28T00:29:26.397Z","Server":"localhost","metadata":{"author":"6001011","status":"temp
","lastModifiedDate":"2012-09-28T00:29:26.366Z"}}
Keep-Alive-Timer, called close()
Keep-Alive-Timer, called closeInternal(true)
Keep-Alive-Timer, SEND TLSv1 ALERT: warning, description = close_notify
Keep-Alive-Timer, WRITE: TLSv1 Alert, length = 32
Keep-Alive-Timer, called closeSocket(selfInitiated)
Could you give me some direction on where the problem may be?
Thanks,
Brendan

I have all other queries in chinese and return correctly.
Also, by comparing the query on filename
where in Windows it show:
%22filename%22:%22%EF%BF%BD%EF%BF%BD%EF%BF%BD%E2%B0%A1.png
but in OSX
%22filename%22:%22%E4%BA%BA%E9%A2%98%E5%95%8A.png
so how so where the convert gone wrong.

Similar Messages

  • File uploads using jQuery with jquery.fileupload.js fails in Firefox over SSL

    Please see the link below where I originally posted the question.
    http://stackoverflow.com/questions/27792614/file-uploads-using-jquery-with-jquery-fileupload-js-fails-in-firefox-over-ssl

    Thanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
    The actual file size: 945,991 bytes
    If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree?

  • Tif files will not import with the same filenames as the .nef files

    When I work on a .nef file, say x.nef, Lightroom 1.0 will allow me to export the x.nef as x.tif to the same folder as the x.nef file resides, but obviously I need to import the x.tif file into the folder for it to show up in LR When I try to import the x.tif file into LR it shows up the the file list OK. When select it and try to import it I get a message telling me that I can't import it as the file x.nef already exists. I didn't select x.nef but x.tif. It will allow me to import it into a different folder, but that is not what I want to do. i need the keep the relevant net and tif files with the same name in the same folder.
    Adobe tech. support suggested; reinstalling, trashing the LR preferences folder, making new databases. None of these solved the problem. In LR beta 4 I could save import tif files with the same file name the .nef with no problem, but not in LR1.0.
    Using Win XP Pro SP2. Pentium P4 3.0 with 2gig ram.
    Has anyone else had this problem. Any assistance appreciated.

    I agree (Adobe) that first the concept that michael.nef and michael.tif and michael.jpg are different files needs to be changed.
    A duplicate is a file that has the same filename and extension and the same content measurements.
    Under the above concept or any concept, ignore duplicates should bring in any file to LR with the same name (contents and measurements) and different extensions.
    I do edit in NEF (more now if I use LR instead of PSE5), do save to PSD, and do save to L/F JPG. If I had to layer in PSD, then I use that for printing, otherwise LR. I always have to make large jpgs to upload to web printing sites, and even small jpgs (now we have the same name and extension (but the measurements would be different) to email. Yes, we do keep copies of an image. I can see where I might want to have the edited .NEF and the PSD in the lib to view, cuz they may have different edits on them.
    MichaelM

  • [Struts]File upload doesnt work with "Create" but works with "CreateInsert"

    Hello,
    thank you for reading this!
    Im facing serious issue with web application built with JSP, Struts & ADF BC in jdeveloper 10.1.3.1 and jdeveloper 10.1.3.2 (same code works perfectly in older jdev versions)
    File upload to DB only works if CreateInsert is selected in PageDefinition. (Have to change from default "Create" to "CreateInsert")
    If I set "Create" i get this problems:
    - if VO is empty the row cannot be created (no error is returned, i click ОК and row is not commited, its just discarded)
    - if VO is not empty instead to create new row current row is updated.
    This only happens with "multipart/form-data" forms. With plain form row is created without the problem.
    If I change to "CreateInsert" then I can add new rows with "multipart/form-data" but i would prefer "Create" because it avoid the blank row issue...
    Old 10.1.3 works with "Create" and "multipart/form-data".
    Im aware of this problem since the 10.1.3.1 release but I havent posted on the forum because I hoped Oracle is aware of this problem but since the problem remains I decided to react. I do not have the metalink account so only way to address the issue is in this forum.
    Please Help.
    Sanja

    I had some problem with 'Create' earlier with 10.1.2. Then I kept recreateing the pages and then it worked finally. How are you creating the page for 'create' event. Is it like, first displaying the rows from the table with create button, or are you right away creating the page from menu option.

  • File Upload Problem - help with a condition

    Dear all,
    I have built a form that includes a file upload. Everything works great until I don't include a file for upload(!) It wont allow me to "not" upload a file, it throws an error at me. My database allows this field to be blank. Do I have to wite some sort of condition that allows the file field to be blank, if so, could anyone help with it?
    Many thanks

    Hello,
    Can any one at Adobe help with this please as I still cannot understand why I am forced to upload a file with the file upload control. What happens if I dont want to add a file with my insert form??? I get errors if I do not include a file:
    Developer Details:
    Folder error. Security Error. Folder 'C:\Inetpub\Www_root\absbiodiesel.co.uk\' is out of base folder 'C:\Inetpub\Www_root\absbiodiesel.co.uk\NewsArticles\'. (FOLDER_DEL_SECURITY_ERROR)
    tNG Execution Trace - VIEW
    tNG_insert.executeTransaction
    STARTER.Trigger_Default_Starter
    tNG_insert.doTransaction
    BEFORE.Trigger_Default_FormValidation
    tNG_insert.prepareSQL
    tNG_insert.executeTransaction - execute sql
    tNG_insert.postExecuteSql
    AFTER.Trigger_FileUpload*
    ERROR.Trigger_Default_Insert_RollBack
    tNG_insert.getRecordset
    tNG_insert.getFakeRsArr
    tNG_insert.getLocalRecordset
    tNG_insert.getFakeRecordset
    tNG_insert.getFakeRecordset

  • FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW

    Hi,
    This is amit Joshi
    I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
    in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
    FileItem fileItemTemp = (FileItem)it.next();
    if (fileItemTemp.isFormField()){
    %>
    <b>Name-value Pair Info:</b>
    Field name: <%= fileItemTemp.getFieldName() %>
    Field value: <%= fileItemTemp.getString() %>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
    optionalFileName = fileItemTemp.getString();
    else
    fileItem = fileItemTemp;
    if (fileItem!=null){
    String fileName = fileItem.getName();
    %>
    <b>Uploaded File Info:</b>
    Content type: <%= fileItem.getContentType() %>
    Field name: <%= fileItem.getFieldName() %>
    File name: <%= fileName %>
    <%
    if(fileItem.getContentType().equals("image/jpeg")) { %>
    File : <p><%
         //response.setContentType("image/gif");
         byte[] bArray=fileItem.get();
         response.setContentType("image/jpeg");
         outputStream=null;
         outputStream= response.getOutputStream();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    else if(fileItem.getContentType().equals("text/plain"))
         %> File : <%= fileItem.getString() %>
    <%
    byte[] bArray=fileItem.get();
    response.setContentType("text/plain");
         outputStream = response.getOutputStream();
         out.println();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    %> </p> <%
    %>
    </body>
    </html>
    Edited by: Amit_Joshi on Nov 13, 2007 10:58 PM

    Well Well Well..
    That would not work...
    What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
    Just as an example
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
       FileItem fileItemTemp = (FileItem)it.next();
    %>
    Name-value Pair Info:
    Field name: <%= fileItemTemp.getFieldName() %><br/>
    Field value: <%= fileItemTemp.getString() %><br/>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
        optionalFileName = fileItemTemp.getString();
    if(!fileTempItem.isFormFiled()){
       String fileName = fileItem.getName();
       fileItem.write(optionalFileName);
    %>
    Uploaded File Info:
    Content type: <%= fileItem.getContentType() %><br/>
    Field name: <%= fileItem.getFieldName() %><br/>
    File name: <%= fileName %><br/>
    <%
    if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
    %>
      <img src="FileServlet?fileName=<%=optionalFileName%>"   
    <%
    %>
    </body>
    </html>a sample code snippet for FileServlet.
    String fileName =  request.getParameter(fileName);
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType("fileName");
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } Hope that might answer your question :)
    However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
    you might think of googling on this and can findout what is the best practise followed for problems of this sort
    REGARDS,
    RaHuL

  • I can no longer print PDF files that were scanned with the very same MX479 on Windows XP, SP3

    I can no longer print PDF files that were scanned with the very same MX479 All-in-One.
    I have an (obsolete) Windows XP, SP3 computer.  Obviously, no updates from Microsoft
    have occurred that might have impacted my Canon Pixma MX479.
    When I attempt to send 1 or more pages from a PDF file to the printer, I don't even get the
    Canon PIXMA popup that would allow me to cancel the print job.
    Yet the Print Queue icon appears in the lower right corner of my monitor.
    If I view the Print Queue, the print queue shows "spooling" and does nothing more.
    If I attempt to CANCEL the print job in the Print Queue, it simply changes to "deleting -
    spooling".
    I cannot cancel the print job that shows NOT RESPONDING via Task Manager, either.
    In fact, the only way the Print Queue icon disappears is if I totally reboot my computer!
    "Luckily", I can still print e-mails, Word documents, and even my downloaded PDF of my
    bank statement.
    So, I was thinking that it was *only* PIXMA'S OWN SCANNED PDFS that could not be
    printed ON THE SAME PIXMA 479.
    However, I have since realized that I also cannot print USPS Signature Proof of Delivery
    PDFs that I received from USPS via e-mail.
    So why can I print *some* PDF files, but not *all* PDF files, like I previously could do?
    THESE SCANS ARE OF LEGAL DOCUMENTS, SO I WILL LIKELY HAVE TO E-MAIL
    THE REQUISITE, PREVIOUSLY SCANNED PDFS TO FEDEX TO PAY FOR *THEM*
    TO PRINT THEM.
    NOTE: I *have* tried turning the PIXMA off, unplugging it, rebooting the computer, plugging
    the PIXM in and restarting the PIXMA - still no ability to print PIXMA-scanned PDFs.
    And, I find it very strange that e-mails, Word documents, and some other PDFs print with
    no problem "around" "NOT RESPONDING" PIXMA print jobs.
    I have owned Canon printers for years, including the MX420, and the MX340.

    There may be some security issues related to the USPS PDFs.
    http://www.certified-mail-envelopes.com/signatures-usps-certified-mail-return-receipt-requested
    I can't help with the scan/print problem. You seem to have done everything I would try.
    I don't know if maybe using a registry cleaner would help.
    John Hoffman
    Conway, NH
    1D Mark IV, Rebel T5i, Pixma PRO-100, MX472

  • Javascript to save as template file in predetermined directory with prompt for filename.

    I've seen a bunch of examples of how to save a regular illustrator file, but I can't seem to find the syntax for saving a file as a .ait file? Am i just missing something incredibly obvious here?? I know this is not right at all.. but this is what i was able to piece together from others' questions.. But i don't see where or how it calls out what kind of file it's saving..?
    anyone care to explain the logic in the newName variable? i copied that directly from another post (and edited the file name at the end). What does "/ARTE\..{2,4}$/i" even mean?
    I'd also like to suppress dialogs while saving as well.
    thanks all.
    var sourceName = app.activeDocument.name;
    var dest = ('/Volumes/customization/library/cads/');
    function saveAsTemplate(destination){
        if(app.documents.length > 0){
            var docRef = app.activeDocument;
            var cadNumber = prompt("What's the number of this CAD?");
            var newName = (sourceName.replace (/ARTE\..{2,4}$/i,'FD-SLOW-SS-' + cadNumber +'.ait');
            var AIT = new File(destination);
            docRef.saveAs(AIT);
    } //end function
    saveAsTemplate(dest);

    Hi williamadowling,
    IMHO it is not possible to save a file as *.ait with scripting (but I don't know).
    williamadowling schrieb:
    … What does "/ARTE\..{2,4}$/i" even mean? …
    This is a part of one of my older threads with the member Ferrarezzi.
    This part of the script in this thread:
    var substituir_sourceName = sourceName.replace (/ARTE\..{2,4}$/i,'DIGITAL.ai');
    means:
    find ARTE and a dot and two or three or four characters before the end of the filename – and replace with DIGITAL.ai
    e.g.:
    The variable for the name of aSample_ARTE.pdf will be changed to aSample_DIGITAL.ai
    Have fun

  • File Upload and Download with XSQL Utility

    Dear all,
    I'm working on a Web-based application to communicate with users.
    This application is based on the XSQL-Utility (XSU).
    Currently I cannot find any possibility to pass an arbitrary
    binary file from the client side to store it in a LOB column
    inside the Oracle RDBMS and vice versa.
    All examples I can find refers to store/read XML-content in CLOB
    columns.
    Thank you for any help.
    Stephan

    Hai Noufal,
        I successfully upload the files to the database.
        For file download i create two views.
       In the first view files are fetched from the database(datatype for the file is image in the database)and it is converted to byte from image.Afterthat the byte is converted to string by using the following code.
    byte source[]=new byte[1024];
                        if(rs.next()){
                             source=rs.getBytes("cv_document_file");
                        String sourcestr=source.toString();
                        wdContext.currentContextElement().setDownloadfile(sourcestr);     
            Now i put the converted string into the second view.In the second view i try to convert the string value into bytes by using the following codes.
    String sourcestr=wdContext.currentContextElement().getDownloadfile();
             byte bs[]=new byte[1024];
             bs=sourcestr.getBytes();
             wdContext.currentDownloadElement().setDownloadfile(bs);
             But it doesn't work and no error.
             Now i am expecting the valuable suggestions from you.
    Thanks in Advance,
    Kind Regards,
    S.V.Selva Bala.

  • Very large file upload 2 GB with Adobe Flash

    Hello, anyone know how can I upload very large files with Adobe Flash or how to use SWFUpload?
    Thanks in Advance, All help will be very appreciated.

    1. yes
    2. I'm getting error message from php
    if( $_FILES['Filedata']['error'] == 0 ){ 
      if(move_uploaded_file( $_FILES['Filedata']['tmp_name'], $uploads_dir.$_FILES['Filedata']['name'] ) ){ 
      echo 'ok'; 
      exit(); 
      echo 'error';    // Overhere
      exit();

  • Multiple file upload in jsp with out using �FILE� type filed.

    I have an applet that is used for multiple file selection, It allows drag and drop functionality also. The problem is once the user selects multiple files it has to get uploaded to the server. Since it�s not part of a file type component while submitting the form we won�t get the file contents.
    We can use multipart api for uploading files, but if the file selected by the user is not by the file type filed the file contents won�t come as part in the jsp submission and I can�t assign the file names selected by the user through the applet to any FILE (hidden ) type in jsp .
    Please give a solution�

    We can use multipart api for uploading files, but if the file selected by the user is not by the file type filed the file contents won&#146;t come as part in the jsp submission and I can&#146;t assign the file names selected by the user through the applet to any FILE (hidden ) type in jsp .Well i think thats a wrong notion which you have...
    you can very well get non-file type field data & file item data from a multipart form.
    Anyways,Letz checkout a simple example(refer to the below Code-snippet down below) which can do that task for us and it uses commons-fileupload & commons-io libraries.
    FileUpload.jsp
    ==========
    <form name="sampleForm" action="uploadAction" method="POST" enctype="multipart/form-data">
      File Name 1: <input type="text" name="fileName1" size="5" /> <br/>
      File: <input type="file" name="file1" id="file1" /> <br/>
      File Name 2: <input type="text" name="fileName2" size="5" /> <br/>
      File: <input type="file" name="file2" id="file2" /> <br/>
      File Name 3: <input type="text" name="fileName3" size="5" /> <br/>
      File: <input type="file" name="file3" id="file3"/> <br/>
      File Name 4: <input type="text" name="fileName4" size="5" /> <br/>
      File: <input type="file" name="file4" id="file4"/> <br/>
      <input type="submit" value="upload"/>
    </form>uploadAction method in (backingBean) :
    ==============================
    public void uploadAction(HttpServletRequest request,HttpServletResponse response)throws Exception{
          FileUploadUtils fuu = new FileUploadUtils(request);
          Map<String,FileItem> fileFields = fuu.getFileFiledsMap();
          Map<String,String> nonfileFields = fuu.getNonFileFiledsMap();
           String fileName1 =  nonfileFields.get("fileName1");
           FileItem file1 = fileFields.get("file1");       
           byte file1ContentBuffer[] = file1.get();
           String file1ContentType = file1.getContentType();
           InputStream file1ins = file1.getInputStream(); 
           file1.write(file1Name);
           String fileName2 =  nonfileFields.get("fileName2");
           FileItem file2 = fileFields.get("file2");
           byte file2ContentBuffer[] = file2.get();
           String file2ContentType = file2.getContentType();
           InputStream file2ins = file2.getInputStream();
           file2.write(file2Name);
    }FileUploadUtils.java:
    ===============
    import java.io.File;
    import java.io.FileOutputStream;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.Iterator;
    import java.util.List;
    import java.util.StringTokenizer;
    import java.util.Vector;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.commons.fileupload.DiskFileUpload;
    import org.apache.commons.fileupload.FileItem;
    import com.gehcsr.utils.dao.DbQueryUtils;
    public class FileUploadUtils {
       private Map<String,FileItem> fileItemMap = null;
       private  Map<String,String> nFileItemMap = null;
       private HttpServletRequest request = null;
       public FileUploadUtils(HttpServletRequest request)throws Exception{
                   this.request = request;    
                   this.fileItemMap = new HashMap<String,FileItem>();
                   this.nFileItemMap = new HashMap<String,String>();
                   this.init();
       private void init() throws Exception{
          DiskFileUpload dfu  = null;
          List fileItems  = null;   
             try{
                   dfu = new DiskFileUpload();
                   dfu.setSizeMax(1000000);
                   dfu.setSizeThreshold(4096);
                   dfu.setRepositoryPath(System.getProperty(java.io.tmpdir));
                   fileItems = dfu.parseRequest(this.request);
                   if(dfu.isMultipartContent && fileItems != null){
                            Iterator iter =  fileItems.iterator();
                  while (iter.hasNext()) {
                       FileItem item = (FileItem) iter.next();           
                                  String fieldName = item.getFieldName(); 
                             if (!item.isFormField()){
                                              String fieldValue = item.toString();
                                               this.nFileItemMap.put(fieldName,fieldName); 
                                         }else
                                             this.fileItemMap.put(fieldName,item);                              
                    }catch(Exception exp){
                         exp.printStackTrace();
                         System.err.println(exp.getMessage());
                         throw new Exception(exp.getCause());
                    } finally{
                       fileItems = null;
                       dfu = null; 
             public  Map<String,FileItem>  getFileFiledsMap(){
                    return this.getFileFiledsMap;
             public Map<String,String> getNonFileFiledsMap(){
                   return this.nFileItemMap;
    NOTE:* Do not forget to add latest versions of commons-fileupload.jar & commons-io.jar in your classpath.You might get few warings due some issues with regards to generics please neglect them.
    and it is not certain that you ought to use commons libraries for this there are many other alternative solutions available by which you can implement a similar functionality.
    Hope this might help !!! if that does do not forget to assign/share duke dollars which you have promised :)
    REGARDS,
    RaHuL

  • How can I deal with case-sensitive filenames referred to inconsistently inside other files?

    I have downloaded into Dreamweaver an existing web site that I'll be taking over from someone else.  The site was built with Microsoft Front Page and apparently now runs on a Windows web server.  While redesigning the site, I'd like to upload it to a web server belonging to me, where I can maintain a work in progress that is accessible to others (so they can give me input as I go along).  But my site is running on a Unix system, where filenames are case-sensitive.
    In the site I've inherited, I've discovered at least one file that is referred to in other files sometimes with one character in upper case and other places in all lower-case.  The actual filename contains the upper case character and locally, on my Windows system, it doesn't matter.  But on the server the file is not found when it is referenced in all lower-case.
    Of course, I can create an all lower-case symlink on my Unix server for the mixed-case file that I know about.  But I don't want to look through every file on the site for other files which may vary, case-wise, in how they are referenced.  Is there any way that Dreamweaver can help me;  for example, by going through and changing all mixed-case filename references inside files, to be consistent with the actual filenames?
    I know this is a lot to ask of Dreamweaver and I'm not optimistic.  But if anyone knows of a solution, I'd appreciate it.

    he means that if you use the file > find function
    (on windows this can be called upoon using CTRL + F)
    you will be able to go through all the files which are cauing you a problem and change their names so that they are all in the same case
    be warned thou
    if case sensitivity is your problem,
    and
    if some code references to your files are written in one case and some are written in the other case, simply changeing the case of the file names will not help.
    what you are trying to do will only work if
    > ALL of the file names are in one case
    or
    > ALL of the files names are the same case
    bcause this will mean you can change the one which does not always match using CTRL + F
    if there is a mix and match on both sides then you are in for a lot of work, if this problem involves multiple names then i would advise you to simply start over!

  • JSF RI 1.0 File Uploads mit Multipart Filter

    Hi there,
    I already posted my problem - I need support for a basic file upload. My requirement is, that I want to access teh file data in a Managed Bean method and then decice what to to with it.
    I decided to use Jason Hunters Multipart Filter, that comes with the oreilly servlet jar file. My problem with the following code is, that the upload() method is never called. I think the filter is not invoked, but I don't know why. Could anyone please see, if I am on the right track?
    First, here is my web.xml with the filter:
         <!-- OReilly MultiPart Filter - by Jason Hunter -->
         <!-- JSF RI 1.0 cannot handle MutliPart Requests -->
    <filter>
    <filter-name>multipartFilter</filter-name>
    <filter-class>com.oreilly.servlet.MultipartFilter</filter-class>
    <!-- we do not specify a special directory, the servlet containers tmp directory is used
    <init-param>
    <param-name>uploadDir</param-name>
    <param-value>/tmp</param-value>
    </init-param>
    -->
    </filter>
    <filter-mapping>
    <filter-name>multipartFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    --> this code comes at the end of my web.xml, so after the jsf cotnroller servlet is configured, etc.
    in my jsp page, I got this form:
    <h:form enctype="multipart/form-data">
    <table width="100%" border="1" cellspacing="2" cellpadding="2">
    <tr>
    <td width="25%" align="right">Bild</td>
    <td width="75%"><input type="file" name="file"></td>
    </tr>
    <tr>
    <td> </td>
    <td><h:commandButton id="upload" action="#{uploadBean.upload}" value="#{messages.uploadFile}"/>
         </td>
    </tr>
    </table>
    </h:form>
    --> the file upload is done with a normal html tag, because there is no jsf tag for it.
    then, here us may upload() method in the managed bean:
    (the upload method is never called... why???? )
         public String upload()
              log.debug("entering upload()...");
              // Files can be read if the request class is MultipartWrapper
              // Init params to MultipartWrapper control the upload handling
              HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
              if (request instanceof MultipartWrapper)
                   log.debug("The MultiPart Filter recognized the mulitpart request.");
                        // Cast the request to a MultipartWrapper
                        MultipartWrapper multi = (MultipartWrapper) request;
                        // Show which files we received
                        Enumeration files = multi.getFileNames();
                        while (files.hasMoreElements())
                             String name = (String) files.nextElement();
                             String filename = multi.getFilesystemName(name);
                             String type = multi.getContentType(name);
                             File f = multi.getFile(name);
                             log.debug("name: " + name);
                             log.debug("filename: " + filename);
                             log.debug("type: " + type);
                             if (f != null)
                                  log.debug("length: " + f.length());
              return "upload";
    THANX! it would be great to get this sample running!

    Hello!
    I have a photo which I store in MSSQL db as a BLOB so it looks like:
    | |
    | Photo |
    | |
    -----------------------+
    | c:\my.jpg | choose |
    -----------------------+
    where
    <f:verbatim>
    <input name="photo" id="photo" type="file">
    </f:verbatim>
    is rendered into standard choose file dialog (unfortunately I can't change it).
    So when user click "choose" it's able to select local file (a picture).
    Then in textbox (input) appear the path (of course it can write it directly).
    A click to the picture
    a) launch javascript:
    onclick="document.getElementById('photo').name='#{DatosPersonalesForm.foto}';"
    that change image value (file name) so I could know which file to look for later:
    <h:graphicImage value="#{DatosPersonalesForm.foto}" ...
    b) after this id calls the actionListener:
    <h:commandLink actionListener="#{DatosPersonalesForm.uploadPhoto}" ...
    In DatosPersonalesForm I have foto property (with get/set) which store foto
    public String getFoto()
    public void setFoto()
    The problem is how to return foto: I put an image in a session and get it from another servlet (registred in web.xml) which intercepts /images/* and return ones from the session.
    I tried use Base64 encoding to embedd images directly, but it works only in Mozilla (even it's html 4.01).
    here is my full DatosPersonalesForm.class (with some additional crap):
    public class DatosPersonalesForm implements Observer, Serializable
    private int idCentro = 1;
    private CurrentClient client;
    private String foto;
    //private String data;
    private Abonado abonado;
    private Persona persona;
    private DireccionTableModel direcciones;
    public DatosPersonalesForm()
    abonado = new Abonado();
    persona = new Persona();
    direcciones = new DireccionTableModel();
    public void setClient(CurrentClient client)
    this.client = client;
    client.addObserver(this);
    public void setIdCentro(int idCentro)
    this.idCentro = idCentro;
    direcciones.setIdCentro(idCentro);
    public void setIdAbonado(int idAbonado)
    if (idAbonado > 0)
    try
    abonado = AbonadoDAO.load(idAbonado, idCentro);
    persona = PersonaDAO.load(idAbonado, idCentro);
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    else
    abonado = new Abonado();
    persona = new Persona();
    direcciones.setIdPersona(idAbonado);
    public Abonado getAbonado() { return abonado; }
    public void setAbonado(Abonado abonado) { this.abonado = abonado; }
    public Persona getPersona() { return persona;}
    public void setPersona(Persona persona) { this.persona = persona; }
    public DireccionTableModel getDirecciones() { return direcciones; }
    public void setDirecciones(DireccionTableModel direcciones) { this.direcciones = direcciones; }
    //public String getData() { return data; }
    public String getFoto()
    if (persona != null)
    try
    Imagenes imagenes = ImagenesDAO.load(persona.getIdImagen(), idCentro);
    if (imagenes != null)
    foto = "/images/" + putImage(imagenes.getImagen());
    //data = Base64Encoder.encode(imagenes.getImagen());
    catch (Exception ex)
    foto = "/img/photo_unavailable.jpg";
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return foto;
    public void setFoto(String foto) { this.foto = foto; }
    public void uploadPhoto(ActionEvent e)
    // for which person to upload???
    if (persona != null)
    HttpServletRequest r = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
    if (r instanceof ServletRequestWrapper)
    ServletRequest req = ((ServletRequestWrapper)r).getRequest();
    if (req instanceof MultipartRequestWrapper)
    MultipartRequestWrapper request = (MultipartRequestWrapper)req;
    byte[] photo = (byte[])request.getFiles().get(foto);
    if (photo != null)
    try
    BufferedImage original = ImageIO.read(new ByteArrayInputStream(photo));
    if (original == null) // not an image?
    return;
    BufferedImage scaled = new BufferedImage(128, 160, BufferedImage.TYPE_INT_RGB);
    Graphics g = (Graphics2D)scaled.getGraphics();
    g.drawImage(original,0,0,128,160,null);
    g.dispose();
    ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
    ImageIO.write(scaled, "jpg", out);
    photo = out.toByteArray();
    catch (IOException ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return;
    Imagenes imagenes = new Imagenes();
    imagenes.setIdCentro(idCentro);
    imagenes.setIdImagenes(persona.getIdImagen());
    imagenes.setImagen(photo);
    try
    ImagenesDAO.save(imagenes);
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return;
    putImage(imagenes.getImagen());
    public String clear()
    if (client != null)
    client.setIdAbonado(0);
    // must be mapped in faces-config.xml
    return "clear";
    public void save(ActionEvent e)
    try
    if (persona.getIdPersona() == 0)
    abonado.setIdCentro(idCentro);
    persona.setIdCentro(idCentro);
    Connection con = DatasourceFactory.getConnection();
    try
    con.setAutoCommit(false);
    PersonaDAO.create(con, persona);
    abonado.setIdAbonado(persona.getIdPersona()); // idPersona == idAbonado is autoGenerated by database
    AbonadoDAO.create(con, abonado);
    con.commit();
    catch(SQLException ex)
    con.rollback();
    persona.setIdPersona(0);
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    finally { con.close(); }
    // notify all about client change
    if (client != null)
    client.setIdAbonado(persona.getIdPersona());
    else
    Connection con = DatasourceFactory.getConnection();
    try
    con.setAutoCommit(false);
    PersonaDAO.save(con, persona);
    AbonadoDAO.save(con, abonado);
    con.commit();
    catch(SQLException ex)
    con.rollback();
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    finally { con.close(); }
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    direcciones.save(e);
    private String putImage(byte[] image)
    String name;
    HttpSession ses = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
    if (ses != null)
    name = "photo_" + String.valueOf(idCentro) + "_" + String.valueOf(persona.getIdPersona()) + ".jpg";
    HashMap map = (HashMap)ses.getAttribute("ImageMap");
    if (map == null)
    map = new HashMap();
    ses.setAttribute("ImageMap", map);
    map.put(name, image);
    else
    name = null;
    return name;
    public void update(Observable o, Object arg)
    if (o instanceof CurrentClient)
    CurrentClient bean = (CurrentClient)o;
    setIdAbonado(bean.getIdAbonado());
    Cheers,
    D.
    P.S. I live in Spain so in Spanish it's foto :-) Sometimes I got crazy coz neither Spanish nor English are my native languages...
    More... in MultipartRequestWrapper you can easy remove
    public Object getAttribute(String name) method. It's my intention to map messages to request properties for easy access (like check if message exists to change style of some textfield in case of error). Do you know the better way???

  • File upload Fails in FireFox on SunRays

    We can't get File upload to work with a Browser Running under SunRays on FireFox
    We have finally identified the http problem (http 417) which is causing the IO flash error.
    We tried this on FireFox 3.0 as well as FireFox 3.5.3 both with the same results. Also, I doubt if this is a browser issue because uploading files to the same servlet from a test JSP page works fine. Whatever happens, happens between flash player and the browser.
    After using a simple MXML file (attached below) to test the file upload functionality on different operating systems we have discovered that it brakes with an unusual error when tested on Solaris.
    We put sniffers and clearly noticed the difference in the headers generated by Flash 10 in different OS environments.
    As you can see from the examples below, the later version (the one running on Solaris) has an extra "Expect:" in the header which we believe is responsible for the HTTP 417 error (which, in its turn, is responsible for 2038 thrown by flex)
    Here is a header generated from a functional system: POST /iehs_core_document/FileUploadServlet HTTP/1.1
    Host: dev01.intelligentehs.com:9086
    Accept: */*
    User-Agent: Shockwave Flash
    Connection: Keep-Alive
    Cache-Control: no-cache
    Content-Length: 755
    Expect: 100-continue
    Content-Type: multipart/form-data; boundary=----------------------------e6d2f5d2c945
    And here is a header generated from OpenSolaris  11 2009.06
    POST /iehs_core_document/FileUploadServlet HTTP/1.1
    Host: dev01.intelligentehs.com:9086
    Accept: */*
    User-Agent: Shockwave Flash
    Connection: Keep-Alive
    Cache-Control: no-cache
    Expect:
    Content-Length: 653
    Expect: 100-continue
    Content-Type: multipart/form-data; boundary=----------------------------b64e06f786e4

    Does anyone deploy to SunRay virtual clients?
    We have a customer who has a ton of them around the world and need to run our Flex based application but File Upload does not work at all... so anyone with any information/ideas on a fix or work around this issue, we would love to hear from you.
    Thanks if advance,
    Anthony

  • File Upload 7.0

    Dear all,
    I have created a planning area using BPS0. I have create da BSP page for the file upload. (new version with htmlb)
    When testing I get the following error:
    The following error text was processed in the system:
    An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause
    Exception class: CX_SY_REF_IS_INITIAL
    Program CL_O24BCVK5TG5265CJ96LKBM7M9JCCP
    Include CL_O24BCVK5TG5265CJ96LKBM7M9JCCM005
    ABAP Class CL_O24BCVK5TG5265CJ96LKBM7M9JC
    Method _ONLAYOUT
    BSP Application Z_KPI_LOG
    BSP Page Z_KPI_LOG2.HTM
    Line 137 
    Long text An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object.
    Can you please help me?
    Points will be assigned
    Thank you
    Ramona L.

    Dear Ramona,
    to find out what is going wrong you can try to debug the application.
    Therefore please open the application Z_KPI_LOG  in SE80 (BSP-Application) and go to page Z_KPI_LOG2.HTM. Here you need to set an external-Breakpoint. Now start the application. During debugging of the page look out for objects which are not instantiated (= initial). As soon as a method should be called for and inital object you get your error message.
    Please note: if you have many objects (e.g. textitems) on the page, it way take some time for you to find out in the debugger which object is initial (= not instantiated).
    The typical reasons for this kind of error in WebInterfaces is:
    - a method for an object should be called, but the object is not instantiated
    The reason why the object is not instantiated could be (in your case):
    - a text for an text element is missing
    - there is an error in the transport (So please compare page Z_KPI_LOG2.HTM in your development system and your system where you are getting the error) or try to transport the application again. Also checked if parts of the application are locked in another transport request.
    Hope this helps.
    Matthias Nutt
    SAP Consulting Switzerland

Maybe you are looking for