I am trying to upload a 3.5MB file ...
Using java Syntax Highlighting
- try {
- // ------------------ CLIENT REQUEST
- FileInputStream fileInputStream = new FileInputStream(new File(
- exsistingFileName));
- // open a URL connection to the Servlet
- URL url = new URL(urlString);
- // Open a HTTP connection to the URL
- conn = (HttpURLConnection) url.openConnection();
- // Allow Inputs
- conn.setDoInput(true);
- // Allow Outputs
- conn.setDoOutput(true);
- // Don't use a cached copy.
- conn.setUseCaches(false);
- // Use a post method.
- conn.setRequestMethod("GET");
- conn.setRequestProperty("Connection", "Keep-Alive");
- conn.setRequestProperty("Content-Type",
- "multipart/form-data;boundary=" + boundary);
- dos = new DataOutputStream(conn.getOutputStream());
- Log.e("MediaPlayer", "Headers are written");
- // create a buffer of maximum size
- bytesAvailable = fileInputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- buffer = new byte[bufferSize];
- // read file and write it into form...
- bytesRead = fileInputStream.read(buffer, 0, bufferSize);
- while (bytesRead > 0) {
- dos.write(buffer, 0, bufferSize);
- bytesAvailable = fileInputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- bytesRead = fileInputStream.read(buffer, 0, bufferSize);
- }
- // send multipart form data necesssary after file data...
- // close streams
- Log.e("MediaPlayer", "File is written");
- fileInputStream.close();
- dos.flush();
- dos.close();
- } catch (MalformedURLException ex) {
- Log.e("MediaPlayer", "error: " + ex.getMessage(), ex);
- }
- catch (IOException ioe) {
- Log.e("MediaPlayer", "error: " + ioe.getMessage(), ioe);
- }
- // ------------------ read the SERVER RESPONSE
- String str = null;
- try {
- //System.gc();
- inStream = new DataInputStream(conn.getInputStream());
- str = inStream.readLine();
- // while ((str = inStream.readLine()) != null) {
- // Log.e("MediaPlayer", "Server Response" + str);
- inStream.close();
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
If the file is big it crashes at the line " inStream = new DataInputStream(conn.getInputStream()); " .. if the file is small then it works absolutely fine.
Can someone help me ???? I use eclipse in windows .. how do i increase the heap size to 16M ? there is a way to increase size in linux .. but that directory structure doesnt exist in my android sdk and i cant find the file where you actually write 16MB instead of 4MB.
Anyways .. does anyone know a way to upload huge files ????? what if someone has to upload a file bigger than 16 MB ?

