2013-08-19 27 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庫或輸出流中的問題。您將需要分解該文件或將一個可用的文件替換爲中斷文件。通過查看堆棧跟蹤中更高的位置並查看崩潰來自哪裏,可以找到哪個組件正在中斷。

相關問題