SUPPORT-8566: fix filePath type in service
This commit is contained in:
parent
ebc3bd4da8
commit
3d918f6cd7
1 changed files with 8 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ package ru.micord.ervu.av.service;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
@ -82,7 +83,7 @@ public class FileUploadService {
|
|||
|
||||
try {
|
||||
FileUrl fileUrl = parseFileUrl(downloadRequest.fileInfo().getFileUrl());
|
||||
String filePath = fileSavingPath + fileUrl.fileName();
|
||||
Path filePath = Paths.get(fileSavingPath, fileUrl.fileName());
|
||||
String downloadUrl = fileUrl.fileUrl();
|
||||
downloadFile(downloadUrl, filePath);
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ public class FileUploadService {
|
|||
fileStatusService.setStatus(fileId, FileStatus.FILE_STATUS_02.status());
|
||||
}
|
||||
else {
|
||||
s3Service.putFile(Paths.get(filePath), fileUrl.fileName());
|
||||
s3Service.putFile(filePath, fileUrl.fileName());
|
||||
|
||||
downloadRequest.fileInfo().setFileUrl(fileUrl.fileName());
|
||||
downloadRequest.fileInfo().setFileStatus(FileStatus.FILE_STATUS_03);
|
||||
|
|
@ -111,7 +112,7 @@ public class FileUploadService {
|
|||
}
|
||||
|
||||
deleteFile(downloadUrl);
|
||||
if (new File(filePath).delete()) {
|
||||
if (filePath.toFile().delete()) {
|
||||
acknowledgment.acknowledge();
|
||||
}
|
||||
}
|
||||
|
|
@ -161,9 +162,9 @@ public class FileUploadService {
|
|||
}
|
||||
}
|
||||
|
||||
private void downloadFile(String fileUrl, String filePath)
|
||||
private void downloadFile(String fileUrl, Path filePath)
|
||||
throws InvalidHttpFileUrlException, FileUploadException {
|
||||
File file = new File(filePath);
|
||||
File file = filePath.toFile();
|
||||
HttpGet request = new HttpGet(fileUrl);
|
||||
|
||||
try (CloseableHttpClient client = HttpClients.createDefault();
|
||||
|
|
@ -195,8 +196,8 @@ public class FileUploadService {
|
|||
}
|
||||
}
|
||||
|
||||
private AvResponse checkFile(String filePath) throws FileUploadException {
|
||||
File file = new File(filePath);
|
||||
private AvResponse checkFile(Path filePath) throws FileUploadException {
|
||||
File file = filePath.toFile();
|
||||
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpPost post = new HttpPost(avRestAddress);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue