当我选择 400M 文件上传时,我的应用程序崩溃了,小于 300M 的上传正常
我改变了这个
int maxBufferSize = 10 * 10241 * 1024;
到
int maxBufferSize = 10241 * 1024;
还是一样的问题
我错过了什么吗?
protected String doInBackground(String... urls) {
String upLoadServerUri = upApi.uploadUrl;
String fileName = this.file_path;
HttpURLConnection connection = null;
DataOutputStream outputStream = null;
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary = "*****";
int bytesRead, bytesAvailable, bufferSize;
byte[] buffer;
int maxBufferSize = 10 * 10241 * 1024;
File sourceFile = new File(fileName);
int sentBytes = 0;
long fileSize = sourceFile.length();
try
{
FileInputStream fileInputStream = new FileInputStream(new File(fileName));
URL url = new URL(upLoadServerUri);
connection = (HttpURLConnection) url.openConnection();
// Allow Inputs & Outputs
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setChunkedStreamingMode(1024);
// Enable POST method
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
outputStream = new DataOutputStream( connection.getOutputStream() );
outputStream.writeBytes(twoHyphens + boundary + lineEnd);
outputStream.writeBytes("Content-Disposition: form-data; name=\"file[]\";filename=\""+ fileName + "\"" + lineEnd);
outputStream.writeBytes(lineEnd);
buffer = new byte[maxBufferSize];
while (true)
{
int bytesToRead = Math.min(maxBufferSize, fileInputStream.available());
// Break if complete
if(bytesToRead == 0){ break; }
// Read bytes
bytesRead = fileInputStream.read(buffer, 0, bytesToRead);
// Write bytes
outputStream.write(buffer, 0, bytesRead);
// Update progress dialog
sentBytes += bytesRead;
// Publish progress
double progress = (double)sentBytes / fileSize;
publishProgress((int)progress);
}
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): ION: alloc_data: handle(0xE4904BC0), len(368640), align(8192), flags(0x2000100), fd_data: handle(0xe4904bc0), fd(0x46)
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): Allocate done for all i/p buffers
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): Allocate done for all o/p buffers
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): OMX_CommandStateSet complete, m_state = 2
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): send_command: Recieved a Command from Client
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): send_command_proxy(): cmd = 0, Current State 2, Expected State 3
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): send_command_proxy(): OMX_CommandStateSet issued
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): Current State 2, Expected State 3
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): send_command_proxy(): Idle-->Executing
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): send_command: Command Processed
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): Rxd OMX_COMPONENT_GENERATE_START_DONE
04-04 23:11:24.664: E/OMX-VDEC-1080P(217): Rxd i/p EOS, Notify Driver that EOS has been reached
04-04 23:11:24.694: E/OMX-VDEC-1080P(217): Output EOS has been reached
04-04 23:11:24.694: E/OMX-VDEC-1080P(217): Rxd OMX_COMPONENT_GENERATE_EOS_DONE
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command: Recieved a Command from Client
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): cmd = 0, Current State 3, Expected State 2
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): OMX_CommandStateSet issued
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Current State 3, Expected State 2
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Command Recieved in OMX_StateExecuting
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): Executing --> Idle
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Driver flush i/p Port complete
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Initiate Input Flush
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Reset all the variables before flusing
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Initialize parser
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): OMX flush i/p Port complete PenBuf(0)
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Driver flush o/p Port complete
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Initiate Output Flush
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): OMX flush o/p Port complete PenBuf(0)
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Rxd OMX_COMPONENT_GENERATE_STOP_DONE
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command: Command Processed
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command: Recieved a Command from Client
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): cmd = 0, Current State 2, Expected State 1
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): OMX_CommandStateSet issued
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): Current State 2, Expected State 1
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command_proxy(): Idle-->Loaded-Pending
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): send_command: Command Processed
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): ION: free: handle(0xEB8C3D00), len(2097152), fd(0x41)
04-04 23:11:24.704: E/OMXNodeInstance(217): OMX_FreeBuffer for buffer header 0x43f34670 successful
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): ION: free: handle(0xDCAB0D00), len(2097152), fd(0x3f)
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): ALL input buffers are freed/released
04-04 23:11:24.704: E/OMXNodeInstance(217): OMX_FreeBuffer for buffer header 0x43f34620 successful
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): ION: free: handle(0xE4904BC0), len(368640), fd(0x46)
04-04 23:11:24.704: E/OMX-VDEC-1080P(217): ION: free: handle(0xD31AE040), len(73728), fd(0x44)
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): ALL output buffers are freed/released
04-04 23:11:24.784: E/OMXNodeInstance(217): OMX_FreeBuffer for buffer header 0x43f348f8 successful
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): OMX_CommandStateSet complete, m_state = 1
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): Playback Ended - PASSED
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): ALL output buffers are freed/released
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): Error in ioctl read next msg
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): omx_vdec: Async thread stop
04-04 23:11:24.784: E/OMX-VDEC-1080P(217): Close the driver instance
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): omx_vdec::component_deinit() complete
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): In OMX vdec Destructor
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): omx_vdec: message thread stop
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): Waiting on OMX Msg Thread exit
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): Waiting on OMX Async Thread exit
04-04 23:11:24.804: E/OMX-VDEC-1080P(217): Exit OMX vdec Destructor