2013-08-19 29 views
2

将近2.1GB的大文件上传到服务器时,我得到一个java.io.IOException: Value too large for defined data type。和我的代码是:对于定义的数据类型,值太大Android

 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 
    . 
    . 

所以任何帮助请。

回答

0

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

相关问题