我正在使用Smack 4.2在聊天应用中工作,我可以以1:1的速度发送短信,现在我想发送图像消息。但我可以清楚地找到任何解决方案。
某些问题是旧版本。
希望有人与我分享任何解决方案或文件。
您可以使用HttpFileUploadManager
上传文件:
try {
HttpFileUploadManager httpFileUploadManager = XmppConnection.getInstance().getHttpFileUploadManager();
XmppConnection.getInstance().discoverHttpService();
final Slot slot = httpFileUploadManager.requestSlot(file.getName(), file.length(), null,
JidCreate.domainBareFrom(Globals.getHttpUploadDomain()));
httpFileUploadManager.uploadFile(file, slot, (uploadedBytes, totalBytes) -> {
Log.d("totalBytes", ">>>" + totalBytes);
Log.d("uploadedBytes", ">>>" + uploadedBytes);
if (totalBytes == uploadedBytes) {
//handle upload success (Send Message with the url in the body? the url is in slot.getGetUrl().toString();)
}
});
} catch (Exception e) {
e.printSackTrace();
//handle failure
}