0

I am trying to POST a image taked with my camera to a PHP script that save the POST into MySQL table.

    Bitmap bm = BitmapFactory.decodeFile(imageurl);

    StringBuilder postDataBuilder = new StringBuilder();
    postDataBuilder.append("[Notas]").append("=").append(URLEncoder.encode(etReclamo.getText().toString(), Constants.UTF8));
    postDataBuilder.append("&").append("image").append("=").append(URLEncoder.encode(getStringImage(bm), Constants.UTF8));

    final byte[] postData = postDataBuilder.toString().getBytes(Constants.UTF8);

    new AsyncTask(){

        @Override
        protected Object doInBackground(Object[] params) {
            try{
                URL url = new URL(Constants.URL_RECLAMO);
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setUseCaches(false);
                conn.setFixedLengthStreamingMode(postData.length);
                conn.setRequestMethod("POST");
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");

                OutputStream out = conn.getOutputStream();
                out.write(postData);

                InputStream is = conn.getInputStream();
                resultado = IOUtils.toString(is);

                out.close();

                int status = conn.getResponseCode();
                if (status == 200) {
                    handler.sendEmptyMessage(RESPUESTA_HTTP_EXITO);
                } else {
                    handler.sendEmptyMessage(RESPUESTA_HTTP_ERROR);
                    throw new IOException("Request failed with error code "
                            + status);
                }

            } catch (IOException e) {
                Log.e("RECLAMO", "IOError");
            }
            return null;
        }
    }.execute(null, null, null);
}

There are no problem sending the string, but I can't store more than 64KB. WHY?

I have tryed BLOB and TEXT type in MySQL. Send and not send the stream length.

  • 2
    The problem is this http://stackoverflow.com/questions/5775571/what-is-the-maximum-length-of-data-i-can-put-in-a-blob-column-in-mysql – markdwhite Dec 02 '15 at 14:31

1 Answers1

1

RTM? http://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

Data Type      Storage Requirement
Blob, Text     L + 2 bytes, where L < 2**16

Blob is a 16bit field, which means it has a 64k size limit

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Marc B
  • 356,200
  • 43
  • 426
  • 500