Change MultipartEntityBuilder.addBinaryBody() function
This commit is contained in:
parent
ee12175eea
commit
7b6a376976
@ -502,7 +502,7 @@ public abstract class AbsSender {
|
||||
if (sendDocument.isNewDocument()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendDocument.CHATID_FIELD, sendDocument.getChatId());
|
||||
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, new java.io.File(sendDocument.getDocument()), ContentType.APPLICATION_OCTET_STREAM, sendDocument.getDocumentName());
|
||||
builder.addBinaryBody(SendDocument.DOCUMENT_FIELD, sendDocument.getNewDocumentFile());
|
||||
if (sendDocument.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendDocument.REPLYMARKUP_FIELD, sendDocument.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
@ -562,7 +562,7 @@ public abstract class AbsSender {
|
||||
if (sendPhoto.isNewPhoto()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendPhoto.CHATID_FIELD, sendPhoto.getChatId());
|
||||
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, new java.io.File(sendPhoto.getPhoto()), ContentType.APPLICATION_OCTET_STREAM, sendPhoto.getPhotoName());
|
||||
builder.addBinaryBody(SendPhoto.PHOTO_FIELD, sendPhoto.getNewPhotoFile());
|
||||
if (sendPhoto.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendPhoto.REPLYMARKUP_FIELD, sendPhoto.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
@ -622,7 +622,7 @@ public abstract class AbsSender {
|
||||
if (sendVideo.isNewVideo()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendVideo.CHATID_FIELD, sendVideo.getChatId());
|
||||
builder.addBinaryBody(SendVideo.VIDEO_FIELD, new java.io.File(sendVideo.getVideo()), ContentType.APPLICATION_OCTET_STREAM, sendVideo.getVideoName());
|
||||
builder.addBinaryBody(SendVideo.VIDEO_FIELD, sendVideo.getNewVideoFile());
|
||||
if (sendVideo.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendVideo.REPLYMARKUP_FIELD, sendVideo.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
@ -701,7 +701,7 @@ public abstract class AbsSender {
|
||||
if (sendSticker.isNewSticker()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendSticker.CHATID_FIELD, sendSticker.getChatId());
|
||||
builder.addBinaryBody(SendSticker.STICKER_FIELD, new java.io.File(sendSticker.getSticker()), ContentType.APPLICATION_OCTET_STREAM, sendSticker.getStickerName());
|
||||
builder.addBinaryBody(SendSticker.STICKER_FIELD, sendSticker.getNewStickerFile());
|
||||
if (sendSticker.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendSticker.REPLYMARKUP_FIELD, sendSticker.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
@ -763,7 +763,7 @@ public abstract class AbsSender {
|
||||
if (sendAudio.isNewAudio()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendAudio.CHATID_FIELD, sendAudio.getChatId());
|
||||
builder.addBinaryBody(SendAudio.AUDIO_FIELD, new java.io.File(sendAudio.getAudio()), ContentType.create("audio/mpeg"), sendAudio.getAudioName());
|
||||
builder.addBinaryBody(SendAudio.AUDIO_FIELD, sendAudio.getNewAudioFile());
|
||||
if (sendAudio.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendAudio.REPLYMARKUP_FIELD, sendAudio.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
@ -831,6 +831,7 @@ public abstract class AbsSender {
|
||||
|
||||
/**
|
||||
* Sends a voice note using Send Voice method (https://core.telegram.org/bots/api#sendvoice)
|
||||
* For this to work, your audio must be in an .ogg file encoded with OPUS
|
||||
* @param sendVoice Information to send
|
||||
* @return If success, the sent Message is returned
|
||||
* @throws TelegramApiException If there is any error sending the audio
|
||||
@ -845,7 +846,7 @@ public abstract class AbsSender {
|
||||
if (sendVoice.isNewVoice()) {
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.addTextBody(SendVoice.CHATID_FIELD, sendVoice.getChatId());
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, new java.io.File(sendVoice.getAudio()), ContentType.create("audio/ogg"), sendVoice.getVoiceName());
|
||||
builder.addBinaryBody(SendVoice.AUDIO_FIELD, sendVoice.getNewVoiceFile());
|
||||
if (sendVoice.getReplayMarkup() != null) {
|
||||
builder.addTextBody(SendVoice.REPLYMARKUP_FIELD, sendVoice.getReplayMarkup().toJson().toString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user