Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File file = new File("//Users//test//Downloads//testimage.jpg");
- log.info("found file: " +file.exists());
- log.info("file size: " +file.length());
- String fieldName = "field";
- String contentType = "image/jpeg";
- boolean isFormField = false;
- String fileName = "testimage.jpg";
- int sizeThreshold = 10240;
- DiskFileItemFactory factory = new DiskFileItemFactory();
- DiskFileItemFactory factory = new DiskFileItemFactory();
- // throws null pointer
- FileItem fi = factory.createItem(fieldName,contentType,isFormField,fileName);
- // so does this one
- DiskFileItem item = new DiskFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold, file);
- MultipartFile f = new CommonsMultipartFile(item);
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2.2</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.0</version>
- </dependency>
- DiskFileItem.getSize()
- final File TEST_FILE = new File("src/test/resources/test.jpg");
- final DiskFileItem diskFileItem = new DiskFileItem("file", "image/jpeg", true, TEST_FILE.getName(), 100000000, TEST_FILE.getParentFile());
- diskFileItem.getOutputStream();
- log.info("found file: " +file.exists());
- log.info("file size: " +file.length());
- File file = new File("//Users//test//Downloads//");
- final File fileToUpload = new File("src/test/resources/files/test.txt");
- final MultiValueMap<String, Object> request = new LinkedMultiValueMap<String, Object>();
- request.add("file", new FileSystemResource(fileToUpload.getAbsolutePath()));
- new DiskFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold, file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement