1 package SnowMailClient.view.html; 2 3 import SnowMailClient.model.multipart.MimePart; 4 import snow.utils.storage.*; 5 import java.io.*; 6 7 9 public class CIDLink 10 { 11 String CID = ""; 12 MimePart mimePart; 13 File file; 14 15 public int posInSource; 17 18 public CIDLink(String cid, int posInSource, MimePart mimePart) throws Exception 19 { 20 this.CID = cid; 21 this.posInSource = posInSource; 22 this.mimePart = mimePart; 23 24 file = File.createTempFile("CIDExtracted", ".jpg"); 26 file.deleteOnExit(); 27 28 writeFile(); 29 } 30 31 public String getCID() { return CID; } 32 33 public int getPosInSource() { return posInSource; } 34 35 public String getAbsolutePath() throws Exception 36 { 37 String path = file.getCanonicalPath(); 38 41 return path; 42 } 43 44 private void writeFile() throws Exception 45 { 46 byte[] cont = mimePart.getByteContent(); 47 if(cont==null) throw new Exception ("CID "+CID+" has null content"); 48 FileUtils.saveToFile(cont, file); 49 } 50 51 52 53 } | Popular Tags |