如何使用Java上传zip文件?

如何使用Java上传zip文件?,java,javascript,dwr,Java,Javascript,Dwr,我正在尝试上载一个zip文件。在我的项目中,我在客户端使用DWR,在服务器端使用Java。正如我在上传数据的DWR教程中所看到的(不在他们的网站上。他们提供了DWR.rar包),他们通过以下几行获得输入 var image = dwr.util.getValue('uploadImage'); var file = dwr.util.getValue('uploadFile'); var color = dwr.util.getValue('color'); dwr.util.getValue

我正在尝试上载一个zip文件。在我的项目中,我在客户端使用DWR,在服务器端使用Java。正如我在上传数据的DWR教程中所看到的(不在他们的网站上。他们提供了DWR.rar包),他们通过以下几行获得输入

var image = dwr.util.getValue('uploadImage');
var file = dwr.util.getValue('uploadFile');
var color = dwr.util.getValue('color');
dwr.util.getValue()是一个获取任何元素值的实用程序,在本例中是一个file对象//在教程中提到

因此,我通过下面的代码使用该实用程序获得一个zip文件

Javascript:

function uploadZip(){
var file = dwr.util.getValue("uploadFile");
dwr.util.setValue("uploadFile", null);
DataUpload.uploadData(file, function(data){
    if(data != null){
        $("#zipURL").html("<p>Upload Completed!!!</p>");
        $("#zipURL").append("Location: "+data.path2);
    }
});
}
<html>
<head>ZIP Uploader
</head>
<body>
<table>
<tr><td>Select File: </td><td><input type="file" id="uploadFile" /></td>
<tr><td><input type="button" value="Upload" onclick="uploadZip()" /></td></tr>    </table>
<div id="result"><span id="imgURL"></span>
<span id="zipURL"></span></div>
</body>
</html>
这段代码运行时没有错误。但是输出是一个空的zip文件。我知道我做错了什么。我找不到

实际上,我收到一个zip文件作为 输入流

我应该怎样写一篇文章 将InputStream(一个zip文件)输入到zip.zip文件 使用java

如果我设置java 方法参数为
ZipFile文件
?我 我还没试过,因为,我是 仍然在寻找一个很好的教程 了解它

任何建议或链接将更加感激!!!!!
提前感谢

这里有两个创建ZIP文件的示例:

下面是一个关于读取ZIP文件的示例:


我也在Java中实现了相同类型的后端代码,我也面临着制作Zip文件的同样问题,但它的内容是空的

后来我发现我向API发出的请求,因为我附加的文件不是
--data binary
格式。因此,我随后以这种格式提出了请求

curl --data-binary @"/mnt/c/checknew.zip" http://localhost/api/upload
我不确定您在
multipart/formdata
Base-64
编码中提出的请求格式


当我发出Base-64编码请求(即
--data binary

时,我的代码工作正常。请您解释一下,为什么我在使用dwr.util.getValue(“文件”)之后仍然使用伪路径。对不起,我无法理解您的意思?就DWR而言,什么是fakepath。
curl --data-binary @"/mnt/c/checknew.zip" http://localhost/api/upload