Skip to content

Commit 53e8a47

Browse files
author
pedro
authored
Merge pull request #18 from TaleLin/fix/file-extension
fix:修复本地文件上传路径不正确的问题
2 parents 3de87ee + 3470aac commit 53e8a47

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/main/java/io/github/talelin/merak/extensions/file/LocalUploader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ public void initStoreDir() {
2525

2626
@Override
2727
protected boolean handleOneFile(byte[] bytes, String newFilename) {
28-
String storePath = getStorePath(newFilename);
28+
String absolutePath =
29+
FileUtil.getFileAbsolutePath(fileProperties.getStoreDir(), getStorePath(newFilename));
2930
try {
3031
BufferedOutputStream stream =
31-
new BufferedOutputStream(new FileOutputStream(new java.io.File(storePath)));
32+
new BufferedOutputStream(new FileOutputStream(new java.io.File(absolutePath)));
3233
stream.write(bytes);
3334
stream.close();
3435
} catch (Exception e) {
@@ -46,7 +47,7 @@ protected FileProperties getFileProperties() {
4647

4748
@Override
4849
protected String getStorePath(String newFilename) {
49-
return FileUtil.getFileAbsolutePath(fileProperties.getStoreDir(), newFilename);
50+
return newFilename;
5051
}
5152

5253
@Override

0 commit comments

Comments
 (0)