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库或输出流中存在问题。您将需要分解该文件,或者用一个有效的组件替换正在分解的组件。通过在堆栈跟踪中向上查找并查看崩溃的来源,可以找到哪个组件正在崩溃