Skip to content

Instantly share code, notes, and snippets.

@cyberrob-zz
Created July 3, 2016 14:35
Show Gist options
  • Save cyberrob-zz/de34596d1c15e76907a700521d9b25c0 to your computer and use it in GitHub Desktop.
Save cyberrob-zz/de34596d1c15e76907a700521d9b25c0 to your computer and use it in GitHub Desktop.
Map<String, RequestBody> map = new HashMap<>();
map.put("data", APIUtils.toRequestBody(new Gson().toJson(matchRequest)));
RequestBody requestBody = RequestBody.create(
MediaType.parse("multipart/form-data"),
FileUtils.file2bytes(new File(audioFilePath))
);
map.put("audio\"; filename=\"match_audio.mp4\"", requestBody);
Client.getInterface()
.createMatch(
PrefUtils.getUserToken(getActivity()),
map
)
.subscribe(new Subscriber<Match>() {
@Override public void onCompleted() {
}
@Override public void onError(Throwable e) {
}
@Override public void onNext(Match match) {
if (match != null) {
Match.printMatchContent(match);
Toast.makeText(getContext(), "Match created!", Toast.LENGTH_SHORT).show();
getActivity().finish();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment