本文介绍了发送文件> 1MB使用HTTP POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发送的视频和音频文件从我的Android应用程序,以 Wampserver
,其中的一些可以得到相当大,我往往会得到出现OutofMemory
当文件大约超过 1MB
的大小问题。
I'm sending video and audio files from my Android application to Wampserver
, some of these can get quite large and I tend to get OutofMemory
issues when the file is approximately over 1MB
in size.
我转换中的每个文件到一个字节流。我认为,字节流太大,因此出现OutofMemory
。
I convert each file individually into a byte stream. I think the byte stream is too large hence the OutofMemory
.
我怎样才能防止出现这个错误?
How can I stop this error from occurring?
推荐答案
使用链接最大信号这里建议:
Using the link Maxium suggested here:
然后我发现这个内存错误的机器人修复错误。
I then found this Out of Memory error in android to fix the error.
替换:
while (bytesRead > 0)
{
outputStream.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
与
while (bytesRead > 0){
bufferSize = Math.min(bytesAvailable, maxBufferSize);
byte byt[]=new byte[bufferSize];
fileInputStream.read(byt);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
outputStream.write(buffer, 0, bufferSize);
}
这篇关于发送文件> 1MB使用HTTP POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!