add(req-2119):测试下载文件到本地
This commit is contained in:
parent
17744baafe
commit
25d8047efe
@ -308,4 +308,24 @@ public class WebFileController {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/v1/obs/testDownload")
|
||||
@CrossOrigin
|
||||
public void testDownload(@Valid ServerFileDownloadDto dto, HttpServletResponse response) {
|
||||
ServerFileDownloadResponse result = fileService.getObject(dto, FileDownloadTypeEnum.STREAM_DOWNLOAD.getCode());
|
||||
try (InputStream inputStream = result.getFileStream()) {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream("/Users/axzo/Desktop/" + result.getFileName());
|
||||
byte[] buffer = new byte[1024];
|
||||
int byteRead;
|
||||
while ((byteRead = inputStream.read(buffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(buffer, 0, byteRead);
|
||||
}
|
||||
|
||||
fileOutputStream.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ public class FileServiceImpl implements FileService {
|
||||
ossFile.setAppCode(fileUploadConfig.getAppCode());
|
||||
ossFile.setChannelCode(fileUploadConfig.getChannelCode());
|
||||
ossFile.setBucketName(fileUploadConfig.getBucketName());
|
||||
ossFile.setDirectory(fileUploadConfig.getDirectory());
|
||||
ossFile.setDirectory(huaWeiCloudObsConfig.getProfilesActive() + SEPARATOR + fileUploadConfig.getDirectory());
|
||||
ossFile.setStatus(FileStatusEnum.STATUS_UPLOAD_FAIL.getCode());
|
||||
ossFile.setStorageUnit(fileUploadConfig.getStorageUnit());
|
||||
ossFile.setStorageSize(fileUploadConfig.getStorageSize());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user