有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法使用DefaultHttpClient发送大文件

我正在尝试使用httpput将大文件传输到服务器。 然而,我无法传输大文件。我收到IOException,并显示错误消息:“系统调用期间发生I/O错误,对等方重置连接”。 我在使用代码:

    // create authenticate client
    DefaultHttpClient client = new DefaultHttpClient(httpParameters);

    // create HTTP put with the file
    HttpPut httpPut = new HttpPut(url);
    final File recordingFile = new File(mDir, mName);
    FileEntity entity = new FileEntity(recordingFile, "binary/octet-stream");
    entity.setChunked(true);
    httpPut.setEntity(entity);
    httpPut.addHeader("Connection", "Keep-Alive");
    httpPut.addHeader("Content-Type", "application/zip");

    // Execute
    HttpResponse res = client.execute(httpPut);
    int statusCode = res.getStatusLine().getStatusCode();

共 (1) 个答案

  1. # 1 楼答案

    我认为您需要更改web中的最大请求大小。配置文件

    <httpRuntime executionTimeout="110" maxRequestLength="8192" />