MCPcopy Create free account
hub / github.com/Vanzaseses/hmdp / createNewFileName

Method createNewFileName

NoteFromVisit/src/test/java/com/sengang/test.java:56–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54 System.out.println(after-current);
55 }
56 @Test
57 public void createNewFileName() {
58 String originalFilename = "niubi.png";
59 // 获取后缀
60 String suffix = StrUtil.subAfter(originalFilename, ".", true);
61 // 生成目录
62 String name = UUID.randomUUID().toString();
63 int hash = name.hashCode();
64 int d1 = hash & 0xF;
65 int d2 = (hash >> 4) & 0xF;
66 // 判断目录是否存在
67 File dir = new File(SystemConstants.IMAGE_UPLOAD_DIR, StrUtil.format("/blogs/{}/{}", d1, d2));
68 if (!dir.exists()) {
69 dir.mkdirs();
70 }
71 // 生成文件名
72 String format = StrUtil.format("/test/{}/{}/{}.{}", d1, d2, name, suffix);
73 }
74
75 @Test
76 public void loadShopData(){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected