Я работаю с angular 7 и при весенней загрузке. Я хочу сохранить файл с текстом арабского языка c. Я отправляю с фронта форму. Данные с помощью этого кода:
const blob = new Blob([content], { type: "application/pdf ; charset=utf-8" });
const reader = new FileReader();
reader.readAsDataURL(blob);
this.formData.append('files', blob,fileName);
, и я использую из backend этот код:
@RequestMapping(value="/uploadFile/")
public UploadFile uploadFile(@RequestParam("files") MultipartFile files) {
try {
log.debug("File : "+files);
fileStorageProperties.setUploadDir("C:/");
fileStorageLocation = Paths.get(fileStorageProperties.getUploadDir()) ;
log.debug("dir"+fileStorageProperties.getUploadDir());
Files.createDirectories(this.fileStorageLocation);
log.debug("$$$$$",fileStorageProperties.getUploadDir());
this.fileStorageService = new FileStorageService(this.fileStorageProperties);
} catch (Exception ex) {
throw new FileStorageException("Could not create the directory where the uploaded files will be stored.", ex);
}
String fileName = this.fileStorageService.storeFile(files);
String fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/api/upload-files/downloadFile/")
.path(fileName)
.toUriString();
return new UploadFile(fileName, fileDownloadUri,
files.getContentType(), String.valueOf(files.getSize()));
}
public String storeFile(MultipartFile file) {
// Normalize file name
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
try {
// Check if the file's name contains invalid characters
if(fileName.contains("..")) {
throw new FileStorageException("Sorry! Filename contains invalid path sequence " + fileName);
}
// Copy file to the target location (Replacing existing file with the same name)
Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
//add owners permission
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.OWNER_EXECUTE);
Path targetLocation = this.fileStorageLocation.resolve(fileName);
Files.copy(file.getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING);
return fileName;
} catch (IOException ex) {
throw new FileStorageException("Could not store file " + fileName + ". Please try again!", ex);
}
}
но проблема в том, что текст arabi c не отображается в файле pdf