wymsee / cordova-HTTP

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
372 stars 301 forks source link

Use uploadFile , but the response without data #136

Open TLideaCreator opened 7 years ago

TLideaCreator commented 7 years ago
this.httpNative.uploadFile(ApiUrl.addAvatar,
      {token: DataProvider.getData<User>(DataProvider.USER_KEY).token},
      {}, filePath, "avatar")
      .then(response => {
        console.log("response is "+JSON.stringify(response));
      })
      .catch(error => {
        this.faultError(faultHandler, ErrorCode.ERROR);
      });

the response is

{
    "status": 200,
    "headers":
    {
        "Access-Control-Allow-Credentials": "true",
        "Content-Type": "text/html; charset=UTF-8",
        "Access-Control-Max-Age": "86400",
        "Access-Control-Allow-Methods": "POST, PATCH, GET, OPTIONS, PUT, DELETE",
        "X-Powered-By": "PHP/7.0.15",
        "Access-Control-Allow-Origin": "*",
        "Date": "Tue, 18 Apr 2017 05:09:47 GMT",
        "Host": "localhost:9000",
        "Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
        "Cache-Control": "no-cache",
        "Connection": "close"
    }
}

the response is with out data , do I lost some config? plugin version is 1.2.0 My system information: Cordova CLI: 6.5.0 Ionic Framework Version: 2.3.0 Ionic CLI Version: 2.2.2 Ionic App Lib Version: 2.2.1 Ionic App Scripts Version: 1.1.4 ios-deploy version: 1.9.1 ios-sim version: 5.0.13 OS: macOS Sierra Node Version: v7.5.0 Xcode version: Xcode 8.3.1 Build version 8E1000a

galikaixin commented 7 years ago

the same with me, i also get without data

galikaixin commented 7 years ago

find the file:CordovaHttpPlugin.m line:178 add the code: [dictionary setObject:responseObject forKey:@"data"];