0

I am working in chat app with Smack 4.2, i can send mes 1:1, now i wanna sent image message. but i can find any solution clearly.

Some question is old version.

Hope someone share me any solution or document.

hà yen
  • 21
  • 3

1 Answers1

1

You can user the HttpFileUploadManager to upload files:

  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
    }
whd.nsr
  • 684
  • 6
  • 12