String fileName = tvFilename.getText().toString();
RequestBody description =
RequestBody.create(
okhttp3.MultipartBody.FORM, fileName);
File fileImage = new File(saveFileName);
RequestBody requestBody1 =
RequestBody.create(MediaType.parse("multipart/form-data"), fileImage);
MultipartBody.Part body =
MultipartBody.Part.createFormData("bannerImage", fileImage.getName(), requestBody1);
RestClient.api().addLive(description, body)
.enqueue(new retrofit2.Callback<ResponseInfo>() {
@Override
public void onResponse(retrofit2.Call<ResponseInfo> call, retrofit2.Response<ResponseInfo> response) {
"处理成功"
}
@Override
public void onFailure(retrofit2.Call<ResponseInfo> call, Throwable t) {
"处理失败"
}
});
@Multipart
@POST("add/live")
Call<ResponseInfo> addLive(
@Part("fileName")RequestBody fileName,//其他字段
@Part MultipartBody.Part bannerImage);//图片
@RequestMapping(value = "/add/live", method = RequestMethod.POST)
@ResponseBody
public ResponseInfo addLive(
@RequestParam(value = "fileName") String fileName,
@RequestParam(value = "bannerImage") MultipartFile bannerImage
)throws Exception {
String logoPath = "/logo/score/";
try {
File file = new File(imagePath + logoPath);
FileUtils.writeByteArrayToFile(file, bannerImage.getBytes());
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseInfo(T1TConstants.SUCCESS, "成功");
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有