Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 改装中的图像上载:内部服务器错误_Android_Image_File Upload_Service_Retrofit2 - Fatal编程技术网

Android 改装中的图像上载:内部服务器错误

Android 改装中的图像上载:内部服务器错误,android,image,file-upload,service,retrofit2,Android,Image,File Upload,Service,Retrofit2,我正在尝试将文件上载到服务器,但responseObject.issucess()返回false。下面是服务和呼叫代码。请让我知道代码有什么问题 要发布的API: @Multipart @POST("/operation/Api/fileSync") Call<SyncResponse> uploadImage( @QueryMap Map<String, String> params, @Part("myfile\"; filename=\"image

我正在尝试将文件上载到服务器,但
responseObject.issucess()
返回
false
。下面是服务和呼叫代码。请让我知道代码有什么问题

要发布的API:

@Multipart
@POST("/operation/Api/fileSync")
Call<SyncResponse> uploadImage(
    @QueryMap Map<String, String> params, 
    @Part("myfile\"; filename=\"image.jpg\" ") RequestBody image
);
@Multipart
@POST(“/operation/Api/fileSync”)
调用上载映像(
@查询映射参数,
@部分(“myfile\”文件名=\“image.jpg\”)请求主体图像
);
和呼叫服务的代码:

public void uploadImage() {

    Retrofit retrofit = RetrofitClientManager
        .getInstance(getApplicationContext())
        .getRetrofitBuilder();
    SyncAPI syncAPI = retrofit.create(SyncAPI.class);

    MediaType MEDIA_TYPE_PNG = MediaType.parse("image/jpeg");
    File file = new File(KEY_NAME);
    RequestBody image = RequestBody.create(MEDIA_TYPE_PNG, file);

    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("AUTHCHECKSUM", authchecksum);
    paramMap.put("name",file.getName());
    paramMap.put("type","image/jpeg");


    Call<SyncResponse> call = syncAPI.uploadImage(paramMap, image);

    try {
        RetrofitClientManager
            .getInstance(getApplicationContext())
            .execute(1, call, this);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
public void uploadImage(){
改装改装=改装客户经理
.getInstance(getApplicationContext())
.getBuilder();
SyncAPI-SyncAPI=reformation.create(SyncAPI.class);
MediaType MEDIA_TYPE_PNG=MediaType.parse(“image/jpeg”);
文件文件=新文件(键名称);
RequestBody image=RequestBody.create(媒体类型PNG,文件);
Map paramMap=新的HashMap();
paramMap.put(“AUTHCHECKSUM”,AUTHCHECKSUM);
put(“name”,file.getName());
paramMap.put(“类型”、“图像/jpeg”);
Call Call=syncAPI.uploadImage(paramMap,image);
试一试{
客户经理
.getInstance(getApplicationContext())
.执行(1,调用,本);
}捕获(不支持的编码异常e){
e、 printStackTrace();
}捕获(JSONException e){
e、 printStackTrace();
}

请尝试使用
类型文件

import retrofit.mime.TypedFile;

@Multipart
@POST("/operation/Api/fileSync")
Call<SyncResponse> uploadImage(
    @QueryMap Map<String, String> params, 
    @Part("image") TypedFile image
)

请尝试使用
类型文件

import retrofit.mime.TypedFile;

@Multipart
@POST("/operation/Api/fileSync")
Call<SyncResponse> uploadImage(
    @QueryMap Map<String, String> params, 
    @Part("image") TypedFile image
)

我使用的是改型版本2,类型文件不受支持。我遇到另一个错误。通过邮递员投递时上载了文件,但不按代码。我使用的是改型版本2,类型文件不受支持。我遇到另一个错误。通过邮递员投递时上载了文件,但不按代码。