em có viết 1 chức năng upload file nhỏ , ở máy local cài window thì chạy được nhưng khi deploy lên heroku server linux thì upload báo thành công nhưng vào thư mục chứa file lại không thấy file
public String uploadFile(MultipartFile file, String path) throws IOException {
String message = "";
try {
if (!file.isEmpty()) {
byte[] bytes = file.getBytes();
//Creating the directory to store file
File dir = new File(path);
// Create the file on server
File serverFile = new File(dir.getAbsolutePath()
+ File.separator + file.getOriginalFilename());
BufferedOutputStream stream = new BufferedOutputStream(
new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();
return dir.getPath() + "/" + file.getOriginalFilename();
}
} catch (Exception e) {
message = e.getMessage();
}
return message;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?