Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 值对于定义的数据类型太大_Android_File Upload_Httpurlconnection_Ioexception - Fatal编程技术网

Android 值对于定义的数据类型太大

Android 值对于定义的数据类型太大,android,file-upload,httpurlconnection,ioexception,Android,File Upload,Httpurlconnection,Ioexception,我得到了一个java.io.IOException:当将一个大约2.1GB的大文件上传到服务器时,该值对于定义的数据类型来说太大了。我的代码是: URL oUrl = new URL(servierUrl); HttpURLConnection connection = (HttpURLConnection) oUrl.openConnection(); connection.setDoOutput(true); connection.setRe

我得到了一个
java.io.IOException:当将一个大约2.1GB的大文件上传到服务器时,该值对于定义的数据类型来说太大了。我的代码是:

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

所以请提供任何帮助。

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