1 16 package net.myvietnam.mvncore.web.fileupload.disk; 17 18 import java.io.File ; 19 20 import net.myvietnam.mvncore.web.fileupload.FileItem; 21 import net.myvietnam.mvncore.web.fileupload.FileItemFactory; 22 23 47 public class DiskFileItemFactory implements FileItemFactory { 48 49 51 52 55 public static final int DEFAULT_SIZE_THRESHOLD = 10240; 56 57 58 60 61 64 private File repository; 65 66 67 70 private int sizeThreshold = DEFAULT_SIZE_THRESHOLD; 71 72 73 75 76 80 public DiskFileItemFactory() { 81 } 82 83 84 94 public DiskFileItemFactory(int sizeThreshold, File repository) { 95 this.sizeThreshold = sizeThreshold; 96 this.repository = repository; 97 } 98 99 100 102 103 112 public File getRepository() { 113 return repository; 114 } 115 116 117 126 public void setRepository(File repository) { 127 this.repository = repository; 128 } 129 130 131 139 public int getSizeThreshold() { 140 return sizeThreshold; 141 } 142 143 144 152 public void setSizeThreshold(int sizeThreshold) { 153 this.sizeThreshold = sizeThreshold; 154 } 155 156 157 159 173 public FileItem createItem( 174 String fieldName, 175 String contentType, 176 boolean isFormField, 177 String fileName 178 ) { 179 return new DiskFileItem(fieldName, contentType, 180 isFormField, fileName, sizeThreshold, repository); 181 } 182 183 } 184 | Popular Tags |