修复返回path不是相对prefix的
This commit is contained in:
parent
5af3a14f03
commit
888698de73
@ -39,7 +39,7 @@ public abstract class AStorageAdapter implements IStorageAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrlForDownload(String... path) {
|
public String getUrlForDownload(String... path) {
|
||||||
return getUrlForUpload(new Date(System.currentTimeMillis() + 1000 * 60 * 60), path);
|
return getUrlForDownload(new Date(System.currentTimeMillis() + 1000 * 60 * 60), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,7 +130,7 @@ final public class AliOssAdapter extends AStorageAdapter {
|
|||||||
}
|
}
|
||||||
return objectList.stream().map(item -> {
|
return objectList.stream().map(item -> {
|
||||||
StorageFileObject object = new StorageFileObject();
|
StorageFileObject object = new StorageFileObject();
|
||||||
object.setPath(item.getKey().substring(0, item.getKey().lastIndexOf("/")));
|
object.setPath(getRelativePath(item.getKey().substring(0, item.getKey().lastIndexOf("/"))));
|
||||||
object.setName(item.getKey().substring(item.getKey().lastIndexOf("/") + 1));
|
object.setName(item.getKey().substring(item.getKey().lastIndexOf("/") + 1));
|
||||||
object.setSize(item.getSize());
|
object.setSize(item.getSize());
|
||||||
object.setRawObject(item);
|
object.setRawObject(item);
|
||||||
@ -179,4 +179,8 @@ final public class AliOssAdapter extends AStorageAdapter {
|
|||||||
return StorageUtil.joinPath(paths);
|
return StorageUtil.joinPath(paths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getRelativePath(String path) {
|
||||||
|
return StorageUtil.getRelativePath(path, config.getPrefix());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,14 @@ public class StorageUtil {
|
|||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getRelativePath(String fullPath, String relativeOn) {
|
||||||
|
if (StringUtils.isBlank(relativeOn)) {
|
||||||
|
fullPath = fullPath.replace(relativeOn, "");
|
||||||
|
}
|
||||||
|
if (fullPath.startsWith("/")) {
|
||||||
|
fullPath = fullPath.substring(1);
|
||||||
|
}
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user