public class IncomingFileTransferEvent extends Event implements GenericDCCEvent
listeners
for this event, which means that all DCC
SEND requests will be ignored by default. If you wish to receive the file,
then you must listen for this event and call the receive method on the
DccFileTransfer object, which connects to the sender and downloads the file.
Example:
DccFileTransfer transfer = event.getTransfer(); // Use the suggested file name. File file = transfer.getFile(); // Receive the transfer and save it to the file, allowing resuming. transfer.receive(file, true);
Warning: Receiving an incoming file transfer will cause a file to be written to disk. Please ensure that you make adequate security checks so that this file does not overwrite anything important!
If you allow resuming and the file already partly exists, it will be appended to instead of overwritten. If resuming is not enabled, the file will be overwritten if it already exists.
FileTransfer
Constructor and Description |
---|
IncomingFileTransferEvent(PircBotX bot,
UserHostmask userHostmask,
User user,
String rawFilename,
String safeFilename,
InetAddress address,
int port,
long filesize,
String token,
boolean passive) |
Modifier and Type | Method and Description |
---|---|
ReceiveFileTransfer |
accept(File destination) |
ReceiveFileTransfer |
acceptAndTransfer(File destination)
Accept the request and transfer the file now, blocking until finished.
|
ReceiveFileTransfer |
acceptResume(File destination,
long startPosition) |
ReceiveFileTransfer |
acceptResumeAndTransfer(File destination,
long startPosition)
Accept the resume request and transfer the file now, blocking until
finished.
|
boolean |
equals(Object o) |
InetAddress |
getAddress() |
long |
getFilesize() |
int |
getPort() |
String |
getRawFilename() |
String |
getSafeFilename() |
String |
getToken() |
String |
getTransferToken()
Deprecated.
Use
getToken() from GenericDCCEvent
interface |
User |
getUser()
The source user that generated the event.
|
UserHostmask |
getUserHostmask()
The source user hostmask that generated the event.
|
int |
hashCode() |
boolean |
isPassive() |
void |
respond(String response)
Respond with a private message to the user that sent the request
|
String |
toString() |
compareTo, getBot, getId, getTimestamp
getBot, getTimestamp
compareTo
public IncomingFileTransferEvent(PircBotX bot, @NonNull UserHostmask userHostmask, User user, @NonNull String rawFilename, @NonNull String safeFilename, @NonNull InetAddress address, int port, long filesize, String token, boolean passive)
@Deprecated public String getTransferToken()
getToken()
from GenericDCCEvent
interfacepublic ReceiveFileTransfer accept(@NonNull File destination) throws IOException
IOException
public ReceiveFileTransfer acceptResume(@NonNull File destination, long startPosition) throws IOException, InterruptedException
IOException
InterruptedException
public ReceiveFileTransfer acceptAndTransfer(File destination) throws IOException
destination
- IOException
public ReceiveFileTransfer acceptResumeAndTransfer(File destination, long startPosition) throws IOException, InterruptedException
destination
- IOException
InterruptedException
public void respond(String response)
respond
in interface GenericEvent
respond
in class Event
response
- The response to send@Generated(value="lombok") public String getRawFilename()
@Generated(value="lombok") public String getSafeFilename()
@Generated(value="lombok") public long getFilesize()
@Nullable @Generated(value="lombok") public User getUser()
GenericUserEvent
getUser
in interface GenericUserEvent
@Generated(value="lombok") public UserHostmask getUserHostmask()
GenericUserEvent
getUserHostmask
in interface GenericUserEvent
@Generated(value="lombok") public InetAddress getAddress()
getAddress
in interface GenericDCCEvent
@Generated(value="lombok") public int getPort()
getPort
in interface GenericDCCEvent
@Generated(value="lombok") public String getToken()
getToken
in interface GenericDCCEvent
@Generated(value="lombok") public boolean isPassive()
isPassive
in interface GenericDCCEvent
Copyright © 2010–2020 Leon Blakey. All rights reserved.