Hello I am working with Netbeans and Java8 right now I am with emulator for 
codenameone. what I try to do is send to the server one zip file I compress 
with codenameone (net.sf.zipme). The zip file works fine but as soon as I 
send it to the server and try to decompress I got the next error: 
 net.lingala.zip4j.exception.ZipException: Expected central directory entry 
not found (#1)

I think maybe is the way I sent the file because if I compress the file 
with codename one and move it manually it works fine, I mean I can unzip 
all the data. if I transfer the file I have got the error in the server.

I try this code to send the zip file to the server from codenameone

 MultipartRequest request = new MultipartRequest();
        request.setPost(true);
        document = FileSystemStorage.getInstance().openInputStream(path + 
zipFileName);
        documentBytes = Util.readInputStream(document);
        request.setUrl(ServerURLEnums.FileApi.getURLPath());
        request.addData(zipFileName, documentBytes, 
"text/html;charset=UTF-8");
        request.addRequestHeader("fileName", zipFileName);
        NetworkManager.getInstance().addToQueue(request);
        request.getResponseData();
        recursiveDelete(path + zipFileName);

and I have got this code in server side 

String fileName = request.getHeader("fileName");
        File saveFile = new File(SAVE_DIR + fileName);

        // prints out all header values
        Enumeration<String> names = request.getHeaderNames();
        while (names.hasMoreElements()) {
            String headerName = names.nextElement();
            System.out.println(headerName + " = " + 
request.getHeader(headerName));
        }
       
        // opens input stream of the request for reading data
        InputStream inputStream = request.getInputStream();

        // opens an output stream for writing file
        FileOutputStream outputStream = new FileOutputStream(saveFile);

        byte[] buffer = new byte[BUFFER_SIZE];
        int bytesRead = -1;

        while ((bytesRead = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, bytesRead);
        }

        outputStream.close();
        inputStream.close();

        System.out.println("File written to: " + 
saveFile.getAbsolutePath());

        // sends response to client
        response.getWriter().print(fileName);


I save the file in the server but with that error. 


I was wondering if you can tell me the correct way to import that sort of 
documents to the server. 

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/328e8eca-eb4d-478c-9082-445caf40e742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to