こんにちは、春のデータを使用してファイルをアップロードしようとしています。ファイルをアップロードしようとすると、例外が発生します。
ファイルアップロードの私のコードは
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();
}
どこTEMPORARY_FILES_DIRECTORY = new File("/home/temp/");
私が得ている例外は
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.
このコードの何が問題なのか、誰か親切に教えてもらえますか。