File Transfer Question

Is there a way to tell what type of file is being transfered before the transfer is accepted. I am wanting to detect certain file types and auto accept them under certain criterion, but I have not found a way to look inside a file before the transfer is accepted. Any help would be greatly appreciated.



The best you can do is look inside the FileTransferRequest instance that you receive in your registered FileTransferListener. I have a similar need to auto accept certain files. What I do is put a known value in the description field of the FileTransferRequest and check for that value on the receiving side. You can also get the mime type, file name, and size from the request. So you could base your auto-acceptance on the mime type value.


The mime-type set on the the request is the type of the file about to be sent. This is set, in Smack at least, by examining the file extension.



Alex’'s answer is correct.



Message was edited by: the.eagle


if Alex’'s answer is really right one (you) might use the “Mark Answer” button so everyone just need to look for the green star to see the right answer.