1 module hunt.http.codec.http.model.MultipartConfig; 2 3 4 /** 5 * Class represntation of an {@link MultipartConfig} annotation value. 6 * 7 * @since Servlet 3.0 8 */ 9 class MultipartConfig { 10 11 private string location; 12 private long maxFileSize; 13 private long maxRequestSize; 14 private int fileSizeThreshold; 15 16 /** 17 * Constructs an instance with defaults for all but location. 18 * 19 * @param location defualts to "" if values is null. 20 */ 21 this(string location) { 22 if (location is null) { 23 this.location = ""; 24 } else { 25 this.location = location; 26 } 27 this.maxFileSize = -1L; 28 this.maxRequestSize = -1L; 29 this.fileSizeThreshold = 0; 30 } 31 32 /** 33 * Constructs an instance with all values specified. 34 * 35 * @param location the directory location where files will be stored 36 * @param maxFileSize the maximum size allowed for uploaded files 37 * @param maxRequestSize the maximum size allowed for 38 * multipart/form-data requests 39 * @param fileSizeThreshold the size threshold after which files will 40 * be written to disk 41 */ 42 this(string location, long maxFileSize, 43 long maxRequestSize, int fileSizeThreshold) { 44 if (location is null) { 45 this.location = ""; 46 } else { 47 this.location = location; 48 } 49 this.maxFileSize = maxFileSize; 50 this.maxRequestSize = maxRequestSize; 51 this.fileSizeThreshold = fileSizeThreshold; 52 } 53 54 55 /** 56 * Gets the directory location where files will be stored. 57 * 58 * @return the directory location where files will be stored 59 */ 60 string getLocation() { 61 return this.location; 62 } 63 64 /** 65 * Gets the maximum size allowed for uploaded files. 66 * 67 * @return the maximum size allowed for uploaded files 68 */ 69 long getMaxFileSize() { 70 return this.maxFileSize; 71 } 72 73 /** 74 * Gets the maximum size allowed for multipart/form-data requests. 75 * 76 * @return the maximum size allowed for multipart/form-data requests 77 */ 78 long getMaxRequestSize() { 79 return this.maxRequestSize; 80 } 81 82 /** 83 * Gets the size threshold after which files will be written to disk. 84 * 85 * @return the size threshold after which files will be written to disk 86 */ 87 int getFileSizeThreshold() { 88 return this.fileSizeThreshold; 89 } 90 }