1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| import static utils.FileUtils.generateFileName; import static utils.UploadUtils.*;
public void upload(String name, String md5, MultipartFile file) throws IOException { String path = UploadConfig.path + generateFileName(); FileUtils.write(path, file.getInputStream()); fileDao.save(new File(name, md5, path, new Date())); }
public void uploadWithBlock(String name, String md5, Long size, Integer chunks, Integer chunk, MultipartFile file) throws IOException { String fileName = getFileName(md5, chunks); FileUtils.writeWithBlok(UploadConfig.path + fileName, size, file.getInputStream(), file.getSize(), chunks, chunk); addChunk(md5,chunk); if (isUploaded(md5)) { removeKey(md5); fileDao.save(new File(name, md5,UploadConfig.path + fileName, new Date())); } }
public boolean checkMd5(String md5) { File file = new File(); file.setMd5(md5); return fileDao.getByFile(file) == null; }
|