i used javamail api to send emails with attachments from java applications, and it is just simple.
File f= new File(file);
MimeBodyPart mbp2 = new MimeBodyPart();
try {
mbp2.attachFile(f);
} catch (IOException e) {
e.printStackTrace();
}
Multipart mp= new MimeMultipart();
mp.addBodyPart(mbp2);
message.setContent(mp);
but the thing i want is to know is how to know the uploading progress of my attachment, unlike httpclient i can’t find an outputstream to writeto!
thanks!
See the method implementation.
You need to override FileDataSource with your custom implementation that tracks file upload.
You should override getInputStream() method to return a FilterOutputStream that count the read bytes. Apache commons-io has CountingInputStream class that can do the job.
Then you simply have to compare the read bytes count with the file length to have a progression.