Quantcast
Channel: Ignite Realtime : Unanswered Discussions - Support
Viewing all articles
Browse latest Browse all 4979

How to transfer file using Smack4.1 in Chat applications?

$
0
0

Here is my code snippet what I have for the file transfer:

 

 

mFTM=FileTransferManager.getInstanceFor(mConnection);
transfer
=  mFTM.createOutgoingFileTransfer(user_name.toLowerCase()+"@52.4.53.212"+"/Smack");
  
try{
  transfer
.sendFile(newFile(profileImagePath),"file");
  
}catch(SmackException e){
  e
.printStackTrace();
  
}

**Code to receive files:**
mFTM
.addFileTransferListener(newFileTransferListener(){
  
@Override
  
publicvoid fileTransferRequest(FileTransferRequest request){
  
if(request!=null){
  
IncomingFileTransfer intransfer=request.accept();
  
try{
  intransfer
.recieveFile();
  
Log.e("inFile", intransfer.recieveFile()+"");
  
}catch(SmackException e){
  e
.printStackTrace();
  
}catch(XMPPException.XMPPErrorException e){
  e
.printStackTrace();
  
}
  
}
  
}
  
});

 

where mFTM is the instance of FileTransferManager.

Any help in this is appriciated.Thank You


Viewing all articles
Browse latest Browse all 4979

Trending Articles