0

My uploading with Ion returned success. But uploaded file was empty.
As packet dump from wireshark, Ion didn't send file contents.

What did I mistake?

Here are my codes.

MyFragment.java

Ion.with(getContext())
        .load(uploadUrl)
        .uploadProgressHandler(new ProgressCallback() {
            @Override
            public void onProgress(long downloaded, long total) {
                LOG.debug("" + downloaded + " / " + total);
            }
        })
        .setMultipartFile("file", new File(currentPhotoPath))
        .asJsonObject()
        .setCallback(new FutureCallback<JsonObject>() {
            @Override
            public void onCompleted(Exception e, JsonObject result) {
                String msg;
                if (e != null) {
                    LOG.error("upload failed:", e);
                } else {
                    LOG.info("upload completed: {}", result.toString());
                }
        });

I'm using android studio 3.0 and LG G version 5.0.

build.gradle android { compileSdkVersion 26 buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "kr.co.digitalpie.dansok"
    minSdkVersion 17  //Android 4.2 Jelly Bean
    targetSdkVersion 26 
    versionCode 55
    versionName "4.0.0"
    multiDexEnabled true
dependencies {
    compile 'com.koushikdutta.ion:ion:2.+'
    ...

Whireshark packet dump

enter image description here

From whireshark, Ion didn't send file correctly.
So I checked my devices local photo was valid.
Uploading photo was located in /storage/emulated/0/Pictures/DigitalPie/P_20171214_141206_2058037049.jpg, and it's size was 350Kbytes.

sungyong
  • 2,267
  • 8
  • 38
  • 66

1 Answers1

0

It caused by totally my silly mistake. Before starting uploading my another asynctask tried to compress it, but failed. Because of it, compressed image was empty.

I found out my mistake by logging as below.

LOG.info("uploading filesize: " + currentPhotoPath.getSize());
Ion.with(getContext())
 ...

The log said uploading filesize: 0.

Hope my silly mistake to help someone.

sungyong
  • 2,267
  • 8
  • 38
  • 66