我有以下代码将图像从Android上传到Web服务器.
它工作正常,只是收到的图像是内容类型八位组流,我需要它是内容类型图像.知道如何设置内容类型吗?
public void sendImage(final Bitmap mBitmap, final String caption, final WebListener webListener) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
AQuery aq = new AQuery(smApplication);
Map<String, Object> params = new HashMap<String, Object>();
params.put("file_name", "name" + (int) (Math.random() * 1000));
params.put("caption", caption);
ByteArrayOutputStream blob = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, blob);
byte[] bitmapdata = blob.toByteArray();
params.put("photo", bitmapdata);
AjaxCallback<JSONObject> ac = new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject object, AjaxStatus status) { …Run Code Online (Sandbox Code Playgroud)