Android java post 图片限制为 64 kb mysql blob
Android java post image limits 64 kb mysql blob
我正在尝试 POST 我的相机拍摄的图像到 PHP 脚本,该脚本将 POST 保存到 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);
}
发送字符串没有问题,但我不能存储超过 64KB。
为什么?
我已经尝试在 MySQL 中输入 BLOB 和 TEXT。
发送和不发送流长度。
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
是一个16bit的字段,也就是说它有64k的大小限制
我正在尝试 POST 我的相机拍摄的图像到 PHP 脚本,该脚本将 POST 保存到 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);
}
发送字符串没有问题,但我不能存储超过 64KB。 为什么?
我已经尝试在 MySQL 中输入 BLOB 和 TEXT。 发送和不发送流长度。
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
是一个16bit的字段,也就是说它有64k的大小限制