Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用两个字符串参数发布zip文件 byte[]binary=FileUtils.readFileToByteArray(reportFile); TypedInput binInput=新的TypedByteArray(“应用程序/zip”,二进制); RestAdapter RestAdapter=new RestAdapter.Builder() .setEndpoint(ContextConstants.REPORT\u SUBMIT\u路径) .build(); restAdapter.setLogLevel(restAdapter.LogLevel.FULL); http=restAdapter.create(CustomHTTPService.class); http.sendReport(stringBuffer.toString(),(userComments!=null)?userComments:,binInput,new Callback(){ @凌驾 public void成功(字符串s,响应){ if(response.getStatus()==200){ } } @凌驾 公共无效失败(错误){ LOGGER.error(“错误代码:+error.getMessage()); } });_Android_Post_Retrofit - Fatal编程技术网

Android 如何使用两个字符串参数发布zip文件 byte[]binary=FileUtils.readFileToByteArray(reportFile); TypedInput binInput=新的TypedByteArray(“应用程序/zip”,二进制); RestAdapter RestAdapter=new RestAdapter.Builder() .setEndpoint(ContextConstants.REPORT\u SUBMIT\u路径) .build(); restAdapter.setLogLevel(restAdapter.LogLevel.FULL); http=restAdapter.create(CustomHTTPService.class); http.sendReport(stringBuffer.toString(),(userComments!=null)?userComments:,binInput,new Callback(){ @凌驾 public void成功(字符串s,响应){ if(response.getStatus()==200){ } } @凌驾 公共无效失败(错误){ LOGGER.error(“错误代码:+error.getMessage()); } });

Android 如何使用两个字符串参数发布zip文件 byte[]binary=FileUtils.readFileToByteArray(reportFile); TypedInput binInput=新的TypedByteArray(“应用程序/zip”,二进制); RestAdapter RestAdapter=new RestAdapter.Builder() .setEndpoint(ContextConstants.REPORT\u SUBMIT\u路径) .build(); restAdapter.setLogLevel(restAdapter.LogLevel.FULL); http=restAdapter.create(CustomHTTPService.class); http.sendReport(stringBuffer.toString(),(userComments!=null)?userComments:,binInput,new Callback(){ @凌驾 public void成功(字符串s,响应){ if(response.getStatus()==200){ } } @凌驾 公共无效失败(错误){ LOGGER.error(“错误代码:+error.getMessage()); } });,android,post,retrofit,Android,Post,Retrofit,接口: byte[] binary = FileUtils.readFileToByteArray(reportFile); TypedInput binInput = new TypedByteArray("application/zip", binary); RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(ContextConstants.REPORT_SUBMIT_PA

接口:

byte[] binary = FileUtils.readFileToByteArray(reportFile);
    TypedInput binInput = new TypedByteArray("application/zip", binary);
    RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint(ContextConstants.REPORT_SUBMIT_PATH)
            .build();
    restAdapter.setLogLevel(RestAdapter.LogLevel.FULL);
    http = restAdapter.create(CustomHTTPService.class);
    http.sendReport(stringBuffer.toString(), (userComments != null) ? userComments : "", binInput, new Callback<String>() {
        @Override
        public void success(String s, Response response) {
            if (response.getStatus() == 200) {

            }
        }

        @Override
        public void failure(RetrofitError error) {
            LOGGER.error("RetrofitError code: " + error.getMessage());
        }
    });
@FormUrlEncoded
@POST(“/收集反馈”)
void sendReport(@Field(“deviceInfo”)字符串deviceInfo,@Field(“garbageInfo”)字符串garbageInfo,
@正文类型输入二进制,回调响应);
我犯了这样的错误:

Reformation.ReformationError:CustomHTTPService.sendReport:@正文参数不能与表单或多部分编码一起使用。(参数#3)


以下是我解决的问题:

@FormUrlEncoded
@POST("/collectFeedback")
void sendReport(@Field("deviceInfo") String deviceInfo, @Field("garbageInfo") String garbageInfo,
                @Body TypedInput binary, Callback<String> response);
@Multipart
@POST(“/收集反馈”)
void sendReport(@Part(“deviceInfo”)类型字符串deviceInfo,@Part(“garbageInfo”)类型字符串garbageInfo,
@部分(“存档”)类型文件,回调响应);
和接口的实现:

@Multipart
@POST("/collectFeedback")
void sendReport(@Part("deviceInfo") TypedString  deviceInfo, @Part("garbageInfo") TypedString  garbageInfo,
                @Part("archive") TypedFile file, Callback<String> response);
TypedString deviceInfo=新的TypedString(stringBuffer.toString());
TypedString garbageInfo=新的TypedString((userComments!=null)?userComments:);
TypedFile archiveFile=新的TypedFile(“应用程序/zip”,报告文件);
RestAdapter RestAdapter=new RestAdapter.Builder()
.setEndpoint(ContextConstants.REPORT\u SUBMIT\u路径)
.build();
http=restAdapter.create(CustomHTTPService.class);
http.sendReport(deviceInfo、garbageInfo、archiveFile、newcallback(){
@凌驾
public void成功(字符串s,响应){
LOGGER.info(“响应代码:+response.getStatus());
if(response.getStatus()==200){
布尔deleteResult=reportHelper.deleteCrashDumpFiles();
LOGGER.info(“删除文件结果:”+deleteResult);
}
}
@凌驾
公共无效失败(错误){
LOGGER.error(“错误代码:+error.getMessage());
}
});
TypedString deviceInfo = new TypedString(stringBuffer.toString());
    TypedString garbageInfo = new TypedString((userComments != null) ? userComments : "");
    TypedFile archiveFile = new TypedFile("application/zip", reportFile);
    RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint(ContextConstants.REPORT_SUBMIT_PATH)
            .build();
    http = restAdapter.create(CustomHTTPService.class);
    http.sendReport(deviceInfo, garbageInfo, archiveFile, new Callback<String>() {
        @Override
        public void success(String s, Response response) {
            LOGGER.info("response code: " + response.getStatus());
            if (response.getStatus() == 200) {
                boolean deleteResult = reportHelper.deleteCrashDumpFiles();
                LOGGER.info("DeleteFile Result: " + deleteResult);
            }
        }

        @Override
        public void failure(RetrofitError error) {
            LOGGER.error("RetrofitError code: " + error.getMessage());
        }
    });