我从图库中选择图像,**发送文本和图像,但我只能看到文本,而不是图像。 **实际上我不想使用Bitmap或压缩文件将我发送到服务器。请指导我如何在不压缩和转换为BitMap的情况下发送我的图像.. 我是在这里使用BitMap但我想删除这个代码
private void uploadData() {
if (etNormalText.getText().toString().trim().isEmpty()) {
Toast.makeText(getApplicationContext(), "Please Type Status", Toast.LENGTH_SHORT).show();
} else if (null != mProgressDialog) {
imageUpload = getStringImage(bitmap);
mProgressDialog.setMessage("Uploading...");
mProgressDialog.show();
mapobject = signatureobject(etNormalText.getText().toString().trim());
new PostStringRequest(CreateStreamActivity.this, mapobject, CreateStreamActivity.this, UPLOAD_TEXT, NetworkUtility.create_stream);
}
}
public String getStringImage(Bitmap bitmap) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
this.bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
byte[] imageBytes = baos.toByteArray();
imageUpload = Base64.encodeToString(imageBytes, Base64.DEFAULT);
return imageUpload;
}
@Override
public void onSuccess(String result, String type) {
if (type.equals(UPLOAD_TEXT)) {
mProgressDialog.dismiss();
Log.d("Create Stream Upload", "onSuccess: " + result);
Toast.makeText(getApplicationContext(), "Posted Successfully...", Toast.LENGTH_SHORT).show();
finish();
}
}
@Override
public void onFailure(int responseCode, String responseMessage) {
}
private Map<String, String> signatureobject(String editNormal) {
mapobject = new HashMap<>();
mapobject.put("access_key", NetworkUtility.accesskey);
mapobject.put("timestamp", Utility.timestamp());
mapobject.put("session_key", NetworkUtility.session_key);
mapobject.put("signature", "");
mapobject.put("text", editNormal);
mapobject.put("media[]", imageUpload);
return mapobject;
}
答案 0 :(得分:2)
答案 1 :(得分:0)