Created
February 1, 2016 07:42
-
-
Save mobimaks/5fc58e921b26c284ec07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void onResponse(Response<UploadServer> response, Retrofit _retrofit) { | |
| UploadServer uploadServer = response.body(); | |
| Uri uploadUrl = Uri.parse(uploadServer.uploadUrl); | |
| RequestBody body = RequestBody.create(MediaType.parse("multipart/form-data"), file); | |
| Call<SavePhoto> savePhotoCall = vkApi.uploadPhoto(uploadUrl.toString(), body); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UploadServer { | |
| @SerializedName("upload_url") | |
| public String uploadUrl; | |
| @SerializedName("album_id") | |
| public long albumId; | |
| @SerializedName("user_id") | |
| public long userId; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface VkApi { | |
| @Multipart | |
| @POST | |
| Call<SavePhoto> uploadPhoto(@Url String url, | |
| @Part("photo\"; filename=\"image.png\" ") RequestBody _file); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment