sunmi-OS/sunmi-openapi-java-sdk

File Upload not working

pc-coholic opened this issue · 6 comments

Hello!

I am currently looking to integrate the App Store API using your API client - everything works pretty well when it comes to retrieving information. I do however face issues when it comes to uploading new apks.

POSTing to the /v2/midplat/filecore/file/uploadApk-endpoit (as provided in the unit-test; see below) results for me in an HTTP 404 error and a response message of {"message":"Not Found"}.

public void uploadFile() throws Exception {
String params = "{\"md5\":\"cfd59674e7c36a4d33d47080740c52c1\",\"file_type_key\":\"appstore_apk\"}";
String url = "https://openapi.sunmi.com/v2/midplat/filecore/file/uploadApk";
String filePath = "/your/path/xxx.apk";
String res = httpClient.uploadFile(url, filePath, params, "hmac");
System.out.println(res);
}

Any idea if the unittest or the upload-function itself might be wrong? Or am I perhaps missing something else?

This is the sample code,can you provide the source code?

I am using exactly the same code as you did in your test - except for providing an updated md5 of the file and - obviously - a different path to the apk...

    public void uploadFile() throws Exception {
        String params = "{\"md5\":\"7e58441db268b3478a3d96a52fa0d9a9\",\"file_type_key\":\"appstore_apk\"}";
        String url = "https://openapi.sunmi.com/v2/midplat/filecore/file/upload";
        String filePath = "/home/martin/Downloads/adcontrol-ad1.apk";
        String res = httpClient.uploadFile(url, filePath, params, "hmac");
        System.out.println(res);
    }

The apk is available from https://support.anydesk.com/downloads/android-addons/adcontrol-ad1.apk

Perhaps the issue is also that I am not uploading to the correct URL? I am also assuming https://openapi.sunmi.com/v2/midplat/filecore/file/upload to be correct because https://docs.sunmi.com/appstore/发布和管理应用接口/ is not showing a specific URL and the links to openapi-internal-doc.test.sunmi.com are not publicly accessible...

The correct URL is https://openapi.sunmi.com/v2/midplat/filecore/file/uploadApk,but it is https://openapi.sunmi.com/v2/midplat/filecore/file/upload in your code

Thank you for pointing this out - I must have changed it during testing...

But even with https://openapi.sunmi.com/v2/midplat/filecore/file/uploadApk, I still get an error 404... Any other ideas, what I might be missing?

Screenshot from 2021-10-25 09-28-41

It‘s ok now,would you please try again?

Thank you - it seems to be working now! :-)