Class HttpFileUploadManager

    • Method Detail

      • getInstanceFor

        public static HttpFileUploadManager getInstanceFor​(XMPPConnection connection)
        Obtain the HttpFileUploadManager responsible for a connection.
        Parameters:
        connection - the connection object.
        Returns:
        a HttpFileUploadManager instance
      • isUploadServiceDiscovered

        public boolean isUploadServiceDiscovered()
        Check if upload service was discovered.
        Returns:
        true if upload service was discovered
      • uploadFile

        public java.net.URL uploadFile​(java.io.File file)
                                throws java.lang.InterruptedException,
                                       XMPPException.XMPPErrorException,
                                       SmackException,
                                       java.io.IOException
        Request slot and uploaded file to HTTP file upload service. You don't need to request slot and upload file separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        file - file to be uploaded
        Returns:
        public URL for sharing uploaded file
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        XMPPException.XMPPErrorException - if there was an XMPP error returned.
        SmackException - if Smack detected an exceptional situation.
        java.io.IOException - in case of HTTP upload errors
      • uploadFile

        public java.net.URL uploadFile​(java.io.File file,
                                       UploadProgressListener listener)
                                throws java.lang.InterruptedException,
                                       XMPPException.XMPPErrorException,
                                       SmackException,
                                       java.io.IOException
        Request slot and uploaded file to HTTP file upload service with progress callback. You don't need to request slot and upload file separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        file - file to be uploaded
        listener - Upload progress listener or null
        Returns:
        public URL for sharing uploaded file
        Throws:
        java.lang.InterruptedException - if the calling thread was interrupted.
        XMPPException.XMPPErrorException - if there was an XMPP error returned.
        SmackException - if Smack detected an exceptional situation.
        java.io.IOException - if an I/O error occurred.
      • uploadFile

        public java.net.URL uploadFile​(java.io.InputStream inputStream,
                                       java.lang.String fileName,
                                       long fileSize)
                                throws XMPPException.XMPPErrorException,
                                       java.lang.InterruptedException,
                                       SmackException,
                                       java.io.IOException
        Request slot and uploaded stream to HTTP upload service. You don't need to request slot and upload input stream separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        inputStream - Input stream used for the upload.
        fileName - Name of the file.
        fileSize - Size of the file.
        Returns:
        public URL for sharing uploaded file
        Throws:
        XMPPException.XMPPErrorException - XMPPErrorException if there was an XMPP error returned.
        java.lang.InterruptedException - If the calling thread was interrupted.
        SmackException - If Smack detected an exceptional situation.
        java.io.IOException - If an I/O error occurred.
      • uploadFile

        public java.net.URL uploadFile​(java.io.InputStream inputStream,
                                       java.lang.String fileName,
                                       long fileSize,
                                       UploadProgressListener listener)
                                throws XMPPException.XMPPErrorException,
                                       java.lang.InterruptedException,
                                       SmackException,
                                       java.io.IOException
        Request slot and uploaded stream to HTTP upload service. You don't need to request slot and upload input stream separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        inputStream - Input stream used for the upload.
        fileName - Name of the file.
        fileSize - file size in bytes.
        listener - upload progress listener or null.
        Returns:
        public URL for sharing uploaded file
        Throws:
        XMPPException.XMPPErrorException - XMPPErrorException if there was an XMPP error returned.
        java.lang.InterruptedException - If the calling thread was interrupted.
        SmackException - If Smack detected an exceptional situation.
        java.io.IOException - If an I/O error occurred.
      • requestSlot

        public Slot requestSlot​(java.lang.String filename,
                                long fileSize)
                         throws java.lang.InterruptedException,
                                XMPPException.XMPPErrorException,
                                SmackException
        Request a new upload slot from default upload service (if discovered). When you get slot you should upload file to PUT URL and share GET URL. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        filename - name of file to be uploaded
        fileSize - file size in bytes.
        Returns:
        file upload Slot in case of success
        Throws:
        java.lang.IllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size supported by the service.
        java.lang.InterruptedException - if the calling thread was interrupted.
        XMPPException.XMPPErrorException - if there was an XMPP error returned.
        SmackException - if smack exception.
      • requestSlot

        public Slot requestSlot​(java.lang.String filename,
                                long fileSize,
                                java.lang.String contentType)
                         throws SmackException,
                                java.lang.InterruptedException,
                                XMPPException.XMPPErrorException
        Request a new upload slot with optional content type from default upload service (if discovered). When you get slot you should upload file to PUT URL and share GET URL. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        filename - name of file to be uploaded
        fileSize - file size in bytes.
        contentType - file content-type or null
        Returns:
        file upload Slot in case of success
        Throws:
        java.lang.IllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size supported by the service.
        SmackException.NotConnectedException - if the XMPP connection is not connected.
        java.lang.InterruptedException - if the calling thread was interrupted.
        XMPPException.XMPPErrorException - if there was an XMPP error returned.
        SmackException - if smack exception.
      • requestSlot

        public Slot requestSlot​(java.lang.String filename,
                                long fileSize,
                                java.lang.String contentType,
                                DomainBareJid uploadServiceAddress)
                         throws SmackException,
                                java.lang.InterruptedException,
                                XMPPException.XMPPErrorException
        Request a new upload slot with optional content type from custom upload service. When you get slot you should upload file to PUT URL and share GET URL. Note that this is a synchronous call -- Smack must wait for the server response.
        Parameters:
        filename - name of file to be uploaded
        fileSize - file size in bytes.
        contentType - file content-type or null
        uploadServiceAddress - the address of the upload service to use or null for default one
        Returns:
        file upload Slot in case of success
        Throws:
        java.lang.IllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size supported by the service.
        SmackException - if Smack detected an exceptional situation.
        java.lang.InterruptedException - if the calling thread was interrupted.
        XMPPException.XMPPErrorException - if there was an XMPP error returned.
      • setTlsContext

        public void setTlsContext​(javax.net.ssl.SSLContext tlsContext)