public final class FileTransferManager extends Manager
Modifier and Type | Method and Description |
---|---|
void |
addFileTransferOfferListener(java.util.function.Consumer<FileTransferOfferEvent> fileTransferOfferListener)
Adds a file transfer listener, which allows to listen for inbound file transfer requests.
|
void |
fileTransferOffered(IQ iq,
java.lang.String sessionId,
java.lang.String mimeType,
FileTransferOffer fileTransferOffer,
java.lang.Object protocol,
FileTransferNegotiator fileTransferNegotiator) |
static java.lang.String |
md5Hash(java.nio.file.Path source)
Calculates the MD5 hash for a file.
|
AsyncResult<FileTransfer> |
offerFile(java.io.File file,
java.lang.String description,
Jid recipient,
java.time.Duration timeout)
Offers a file to another user.
|
AsyncResult<FileTransfer> |
offerFile(java.io.InputStream source,
java.lang.String fileName,
long fileSize,
java.time.Instant lastModified,
java.lang.String description,
Jid recipient,
java.time.Duration timeout)
Offers a stream to another user.
|
AsyncResult<FileTransfer> |
offerFile(java.io.InputStream source,
java.lang.String fileName,
long fileSize,
java.time.Instant lastModified,
java.lang.String description,
Jid recipient,
java.time.Duration timeout,
java.lang.String sessionId)
Offers a stream to another user.
|
AsyncResult<FileTransfer> |
offerFile(java.io.InputStream source,
java.lang.String fileName,
long fileSize,
java.time.Instant lastModified,
java.lang.String description,
Jid recipient,
java.time.Duration timeout,
java.lang.String sessionId,
java.lang.String mimeType,
java.lang.String hash)
Offers a stream to another user.
|
AsyncResult<FileTransfer> |
offerFile(java.nio.file.Path source,
java.lang.String description,
Jid recipient,
java.time.Duration timeout)
Offers a file to another user.
|
AsyncResult<FileTransfer> |
offerFile(java.nio.file.Path source,
java.lang.String description,
Jid recipient,
java.time.Duration timeout,
java.lang.String mimeType,
boolean calculateHash)
Offers a file to another user.
|
AsyncResult<IQ> |
offerFile(java.net.URI uri,
java.lang.String description,
Jid recipient,
java.time.Duration timeout)
Offers a file to another user in form of an URL.
|
AsyncResult<IQ> |
offerFile(java.net.URL url,
java.lang.String description,
Jid recipient,
java.time.Duration timeout)
Deprecated.
|
void |
removeFileTransferOfferListener(java.util.function.Consumer<FileTransferOfferEvent> fileTransferOfferListener)
Removes a previously added file transfer listener.
|
isEnabled, setEnabled
public static java.lang.String md5Hash(java.nio.file.Path source) throws java.io.IOException
Calculates the MD5 hash for a file. The returned string is hex encoded.
source
- The source path.java.io.IOException
- If the file could not be read.@Deprecated public final AsyncResult<IQ> offerFile(java.net.URL url, java.lang.String description, Jid recipient, java.time.Duration timeout)
offerFile(URI, String, Jid, Duration)
Offers a file to another user in form of an URL. The file can be downloaded by the recipient via an HTTP GET request. If this method returns without exception you can assume, that the file has been successfully downloaded by the recipient.
url
- The URL of the file.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).public final AsyncResult<IQ> offerFile(java.net.URI uri, java.lang.String description, Jid recipient, java.time.Duration timeout)
Offers a file to another user in form of an URL. The file can be downloaded by the recipient via an HTTP GET request. If this method returns without exception you can assume, that the file has been successfully downloaded by the recipient.
uri
- The URI of the file.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).public final AsyncResult<FileTransfer> offerFile(java.io.File file, java.lang.String description, Jid recipient, java.time.Duration timeout) throws java.io.IOException
Offers a file to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
file
- The file.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).java.io.IOException
- If the file can’t be read.public final AsyncResult<FileTransfer> offerFile(java.nio.file.Path source, java.lang.String description, Jid recipient, java.time.Duration timeout) throws java.io.IOException
Offers a file to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
source
- The file.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).java.io.IOException
- If the file can’t be read.public final AsyncResult<FileTransfer> offerFile(java.nio.file.Path source, java.lang.String description, Jid recipient, java.time.Duration timeout, java.lang.String mimeType, boolean calculateHash) throws java.io.IOException
Offers a file to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
source
- The file.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).mimeType
- The mime type. If null, the mime type is guessed.calculateHash
- If true, the MD5 hash for the file is calculated and included in the offer.java.io.IOException
- If the file can’t be read.public final AsyncResult<FileTransfer> offerFile(java.io.InputStream source, java.lang.String fileName, long fileSize, java.time.Instant lastModified, java.lang.String description, Jid recipient, java.time.Duration timeout)
Offers a stream to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
source
- The stream.fileName
- The file name.fileSize
- The file size.lastModified
- The last modified date.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).public final AsyncResult<FileTransfer> offerFile(java.io.InputStream source, java.lang.String fileName, long fileSize, java.time.Instant lastModified, java.lang.String description, Jid recipient, java.time.Duration timeout, java.lang.String sessionId)
Offers a stream to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
source
- The stream.fileName
- The file name.fileSize
- The file size.lastModified
- The last modified date.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).sessionId
- The session id.public final AsyncResult<FileTransfer> offerFile(java.io.InputStream source, java.lang.String fileName, long fileSize, java.time.Instant lastModified, java.lang.String description, Jid recipient, java.time.Duration timeout, java.lang.String sessionId, java.lang.String mimeType, java.lang.String hash)
Offers a stream to another user. If this method returns successfully, the recipient has accepted the offer, the stream method has been negotiated and the file is ready to be transferred. Call FileTransfer.transfer()
to start the file transfer.
source
- The stream.fileName
- The file name.fileSize
- The file size.lastModified
- The last modified date.description
- The description of the file.recipient
- The recipient’s JID (must be a full JID for client-to-client file transfers, i. e. including resource
).timeout
- The timeout (indicates how long to wait until the file offer has either been accepted or rejected).sessionId
- The session id.mimeType
- The mime type. If null, the mime type is guessed.hash
- The hash (maybe null). As per the specification this should be a hex-encoded MD5 hash.md5Hash(Path)
public void fileTransferOffered(IQ iq, java.lang.String sessionId, java.lang.String mimeType, FileTransferOffer fileTransferOffer, java.lang.Object protocol, FileTransferNegotiator fileTransferNegotiator)
public void addFileTransferOfferListener(java.util.function.Consumer<FileTransferOfferEvent> fileTransferOfferListener)
Adds a file transfer listener, which allows to listen for inbound file transfer requests.
fileTransferOfferListener
- The listener.removeFileTransferOfferListener(Consumer)
public void removeFileTransferOfferListener(java.util.function.Consumer<FileTransferOfferEvent> fileTransferOfferListener)
Removes a previously added file transfer listener.
fileTransferOfferListener
- The listener.addFileTransferOfferListener(Consumer)
Copyright © 2014–2019 XMPP.rocks. All rights reserved.