【问题标题】:Value too large for defined data type Android值对于定义的数据类型 Android 太大
【发布时间】:2013-08-21 10:08:15
【问题描述】:

在向服务器上传将近 2.1GB 的大文件时,我收到了 java.io.IOException: Value too large for defined data type。我的代码是:

     URL oUrl = new URL(servierUrl);
     HttpURLConnection  connection = (HttpURLConnection) oUrl.openConnection();
       connection.setDoOutput(true);
       connection.setRequestMethod("POST");
       connection.setRequestProperty("Connection", "Keep-Alive");
       connection.setRequestProperty("Content-Type", "multipart/form-       data");
       connection.setRequestProperty("Content-Length", String.valueOf(nChunkSize));
       connection.setConnectTimeout(1800000); 

     InputStream oFileInputStream = new FileInputStream(new File(sFilePath));

     OutputStream outputStream = new DataOutputStream(connection.getOutputStream());
     .
     .
     . // here I'm dividing the stream chunks, every chunk 5Mb and uploading the chuck  to server 
          but in the chunk #410 (5Mb * 410) it cause an exception return the exception as I mentioned above.
          before that every chunk I upload it success
     .
     .

所以请帮忙。

【问题讨论】:

    标签: android file-upload httpurlconnection ioexception


    【解决方案1】:

    我的猜测是使用 int 来保存文件的长度。这在 2^31-1 或大约 20 亿字节处溢出。看起来像 http 库或输出流中的问题。您将需要分解该文件或将破坏组件替换为有效的组件。通过在堆栈跟踪中向上查找并查看崩溃来自何处,可以找到哪个组件正在破坏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      相关资源
      最近更新 更多