public final class HttpFileUploadManager extends Manager
| Modifier and Type | Field and Description |
|---|---|
static String |
NAMESPACE
Namespace of XEP-0363 v0.4 or higher.
|
static String |
NAMESPACE_0_2
Namespace of XEP-0363 v0.2 or lower.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
discoverUploadService()
Discover upload service.
|
UploadService |
getDefaultUploadService()
Get default upload service if it was discovered.
|
static HttpFileUploadManager |
getInstanceFor(XMPPConnection connection)
Obtain the HttpFileUploadManager responsible for a connection.
|
boolean |
isUploadServiceDiscovered()
Check if upload service was discovered.
|
static UploadService.Version |
namespaceToVersion(String namespace) |
Slot |
requestSlot(String filename,
long fileSize)
Request a new upload slot from default upload service (if discovered).
|
Slot |
requestSlot(String filename,
long fileSize,
String contentType)
Request a new upload slot with optional content type from default upload service (if discovered).
|
Slot |
requestSlot(String filename,
long fileSize,
String contentType,
org.jxmpp.jid.DomainBareJid uploadServiceAddress)
Request a new upload slot with optional content type from custom upload service.
|
void |
setTlsContext(SSLContext tlsContext) |
URL |
uploadFile(File file)
Request slot and uploaded file to HTTP file upload service.
|
URL |
uploadFile(File file,
UploadProgressListener listener)
Request slot and uploaded file to HTTP file upload service with progress callback.
|
void |
useTlsSettingsFrom(ConnectionConfiguration connectionConfiguration) |
connection, getAuthenticatedConnectionOrThrow, schedulepublic static final String NAMESPACE
public static final String NAMESPACE_0_2
public static HttpFileUploadManager getInstanceFor(XMPPConnection connection)
connection - the connection object.public boolean discoverUploadService() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
XMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NoResponseExceptionpublic boolean isUploadServiceDiscovered()
public UploadService getDefaultUploadService()
public URL uploadFile(File file) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException
file - file to be uploadedInterruptedExceptionXMPPException.XMPPErrorExceptionSmackExceptionIOException - in case of HTTP upload errorspublic URL uploadFile(File file, UploadProgressListener listener) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException
file - file to be uploadedlistener - upload progress listener of nullInterruptedExceptionXMPPException.XMPPErrorExceptionSmackExceptionIOExceptionpublic Slot requestSlot(String filename, long fileSize) throws InterruptedException, XMPPException.XMPPErrorException, SmackException
filename - name of file to be uploadedfileSize - file size in bytes.IllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size
supported by the service.InterruptedExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionSmackException.NoResponseExceptionSmackExceptionpublic Slot requestSlot(String filename, long fileSize, String contentType) throws SmackException, InterruptedException, XMPPException.XMPPErrorException
filename - name of file to be uploadedfileSize - file size in bytes.contentType - file content-type or nullIllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size
supported by the service.SmackException.NotConnectedExceptionInterruptedExceptionXMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackExceptionpublic Slot requestSlot(String filename, long fileSize, String contentType, org.jxmpp.jid.DomainBareJid uploadServiceAddress) throws SmackException, InterruptedException, XMPPException.XMPPErrorException
filename - name of file to be uploadedfileSize - file size in bytes.contentType - file content-type or nulluploadServiceAddress - the address of the upload service to use or null for default oneIllegalArgumentException - if fileSize is less than or equal to zero or greater than the maximum size
supported by the service.SmackExceptionInterruptedExceptionXMPPException.XMPPErrorExceptionpublic void setTlsContext(SSLContext tlsContext)
public void useTlsSettingsFrom(ConnectionConfiguration connectionConfiguration)
public static UploadService.Version namespaceToVersion(String namespace)