simple HttpURLConnection POST file multipart/form-data from android to google blobstore

前端 未结 4 1786
日久生厌
日久生厌 2020-11-28 05:08

I have very little idea how html works.What i want to do is exactly similar to the following but on android

4条回答
  •  天命终不由人
    2020-11-28 05:34

    As alternative you can use Retrofit.

    You can specify a call like this:

    @Multipart
    @POST("/user/photo")
    Call updateUser(@Part("photo") RequestBody photo, @Part("description") RequestBody description);
    

    then create it like this:

    Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://api.github.com")
        .build();
    GitHubService service = retrofit.create(GitHubService.class);
    

    and finally execute it like this:

    service.updateUser(Photo, description).enqueue() --> asynchronous

    service.updateUser(Photo, description).execute() --> synchronous

    See the documentation here

提交回复
热议问题