Skip to content

Instantly share code, notes, and snippets.

@mobimaks
Created February 1, 2016 07:42
Show Gist options
  • Select an option

  • Save mobimaks/5fc58e921b26c284ec07 to your computer and use it in GitHub Desktop.

Select an option

Save mobimaks/5fc58e921b26c284ec07 to your computer and use it in GitHub Desktop.
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);
}
public class UploadServer {
@SerializedName("upload_url")
public String uploadUrl;
@SerializedName("album_id")
public long albumId;
@SerializedName("user_id")
public long userId;
}
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