Skip to content

Commit

Permalink
feat: optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
itning committed Feb 13, 2024
1 parent 706aa80 commit a97a28c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void ts(@PathVariable String name, @PathVariable String index, HttpServle
*/
@GetMapping("/video/{path}")
public void videoForPath(@PathVariable String path, HttpServletRequest request, HttpServletResponse response) throws Exception {
byte[] decode = Base64.getDecoder().decode(path.getBytes(StandardCharsets.UTF_8));
byte[] decode = Base64.getUrlDecoder().decode(path.getBytes(StandardCharsets.UTF_8));
Path p = Paths.get(new String(decode, StandardCharsets.UTF_8));
MultipartFileSender.fromPath(p)
.with(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Link {
}

public static List<Link> build(String location) throws UnsupportedEncodingException {
byte[] decode = Base64.getDecoder().decode(location.getBytes(StandardCharsets.UTF_8));
byte[] decode = Base64.getUrlDecoder().decode(location.getBytes(StandardCharsets.UTF_8));
String decodeLocation = new String(decode, StandardCharsets.UTF_8);
String[] locationArray = decodeLocation.split(SPLIT_REGEX);
List<Link> linkList = new ArrayList<>(locationArray.length);
Expand All @@ -46,7 +46,7 @@ public static List<Link> build(String location) throws UnsupportedEncodingExcept
for (int i = 0; i < locationArray.length; i++) {
Link link = new Link();
link.setName(locationArray[i]);
link.setLink(Base64.getEncoder().encodeToString(last.toString().getBytes(StandardCharsets.UTF_8)));
link.setLink(Base64.getUrlEncoder().encodeToString(last.toString().getBytes(StandardCharsets.UTF_8)));
if ((i + 1) != locationArray.length) {
last.append(File.separator).append(locationArray[i + 1]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<FileEntity> getFileEntities(String location) {
if (StringUtils.isBlank(location)) {
files = File.listRoots();
} else {
byte[] decode = Base64.getDecoder().decode(location);
byte[] decode = Base64.getUrlDecoder().decode(location);
File file = new File(new String(decode, StandardCharsets.UTF_8));
files = file.listFiles();
}
Expand All @@ -57,7 +57,7 @@ public List<FileEntity> getFileEntities(String location) {
fileEntity.setSize(FileUtils.byteCountToDisplaySize(f.length()));
fileEntity.setFile(f.isFile());
fileEntity.setCanPlay(isVideoFile(f.getName()));
fileEntity.setLocation(Base64.getEncoder().encodeToString(f.getPath().getBytes(StandardCharsets.UTF_8)));
fileEntity.setLocation(Base64.getUrlEncoder().encodeToString(f.getPath().getBytes(StandardCharsets.UTF_8)));
fileEntities.add(fileEntity);
}
} else {
Expand Down

0 comments on commit a97a28c

Please sign in to comment.