0
안녕하세요, 저는 스프링 데이터를 사용하여 파일을 업로드하려고합니다. 파일을 업로드하려고하면 예외가 발생합니다. 내가 점점 오전 예외는 TEMPORARY_FILES_DIRECTORY = new File("/home/temp/");
파일 업로드 spring 데이터 - gridfs
파일 업로드에 대한 나의 코드가
try {
File file = new File(this.TEMPORARY_FILES_DIRECTORY, Calendar.getInstance().getTimeInMillis() + "_" + fileNameUnderscored);
writeByteArrayToFile(file, form.getFile().getBytes());
FileInputStream inputStream = new FileInputStream(file);
GridFSFile gridFSFile = gridFsTemplate.store(inputStream, "test.png");
PropertyImage img = new PropertyImage();
img.setPropertyUid(gridFSFile.getFilename());
imagesRepository.save(img);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
디버깅에
java.io.IOException: File '/home/temp/1392807425028_file' could not be created
FileUtils
클래스
if (parent.mkdirs() == false) {
throw new IOException("File '" + file + "' could not be created");
}
parent.mkdirs() is false.
,
아무도 친절하게이 코드의 잘못된 점을 말해 줄 수 있습니까?
답장을 보내 주셔서 감사합니다./home/username/temp로 변경했는데 [답변 허용] - '/ tmp'사용 제안, +1 – Shahzeb