简体   繁体   English

在服务器上上传图像而不转换为BITMAP

[英]Upload Image on Server Without converting into BITMAP

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 请指导他们如何发送我的图像而不进行压缩和转换成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;

}

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 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. 我们只需要传递您将从图库中获得的图像路径即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM