80,351
社区成员
发帖
与我相关
我的任务
分享
public interface SendstoryAPI {
@Multipart
@POST("/index.php/home/Interface/sendStory")
Call<String> registerUser(@PartMap Map<String, RequestBody> params);
}
Retrofit retrofit = new Retrofit.Builder().baseUrl("http://139.129.19.51/story/")
.addConverterFactory(GsonConverterFactory.create())
.build();
SendstoryAPI sendstory = retrofit.create(SendstoryAPI.class);
File file = new File(Environment.getExternalStorageDirectory(), "my.jpg");
RequestBody photo = RequestBody.create(MediaType.parse("multipart/form-data"),file);
Map<String,RequestBody> photos = new HashMap<>();
photos.put("photo[]\"; filename=\"icon.png", photo);
photos.put("uid", RequestBody.create(null, app.myID));
photos.put("story_info", RequestBody.create(null, content));
photos.put("userpass", RequestBody.create(null, app.myPASS));
photos.put("lng", RequestBody.create(null, "18.00"));
photos.put("lat", RequestBody.create(null, "19.00"));
photos.put("city", RequestBody.create(null, "北京"));
sendstory.registerUser(photos).enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
Log.i("--------",response.body().toString());
}
@Override
public void onFailure(Call<String> call, Throwable t) {
}
});