Reputation: 402
I am Selecting Image from Gallery, ** sending Text and Image but I am able to see only Text, Not Image. **Actually I don't want to use Bitmap or compress file which I am sending over to Server. Please guide em how can I send My Image without compressing and Converting into BitMap.. I am using here BitMap but I want To REMOVE THIS CODE
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;
}
Upvotes: 0
Views: 919
Reputation: 883
Please refer this link you may get the answer. http://www.androidhive.info/2014/12/android-uploading-camera-image-video-to-server-with-progress-bar/
Upvotes: 0
Reputation: 294
We Can Upload Images to server without Converting to Bitmap Check This Link
https://guides.codepath.com/android/Networking-with-the-Fast-Android-Networking-Library
we just need to pass the image path which you will get from the gallary.
Upvotes: 2