2025年4月21日16:47:17
parent
9699a6f811
commit
a345943568
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 MiB |
|
|
@ -0,0 +1,14 @@
|
|||
> 一个简单的minio的客户端
|
||||
|
||||

|
||||
|
||||
### 1.功能
|
||||
|
||||
- 创建bucket
|
||||
- 上传文件
|
||||
|
||||

|
||||
|
||||
- url预览
|
||||
|
||||

|
||||
|
|
@ -21,6 +21,11 @@ import javafx.scene.layout.AnchorPane;
|
|||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
@ -111,10 +116,31 @@ public class MinioController {
|
|||
|
||||
// 创建上下文菜单
|
||||
final ContextMenu contextMenu = new ContextMenu();
|
||||
MenuItem copyUrl = new MenuItem("copy url");
|
||||
|
||||
copyUrl.setOnAction(event -> {
|
||||
|
||||
BucketFile selectedItem = tableview.getSelectionModel().getSelectedItem();
|
||||
|
||||
|
||||
// 获取系统剪贴板
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
|
||||
// 创建一个 StringSelection 对象,该对象封装了要复制的文本
|
||||
Transferable transferableText = new StringSelection(selectedItem.getUrl());
|
||||
|
||||
// 将文本内容设置到剪贴板
|
||||
clipboard.setContents(transferableText, null);
|
||||
|
||||
});
|
||||
|
||||
MenuItem menuItem = new MenuItem("删除");
|
||||
menuItem.setOnAction(event -> {
|
||||
list.remove(tableview.getSelectionModel().getSelectedItem());
|
||||
// MinioUtils.delete_file();
|
||||
});
|
||||
|
||||
contextMenu.getItems().add(copyUrl);
|
||||
contextMenu.getItems().add(menuItem);
|
||||
// 添加事件监听器来处理上下文菜单的显示
|
||||
tableview.setOnContextMenuRequested(event -> {
|
||||
|
|
@ -178,6 +204,9 @@ public class MinioController {
|
|||
|
||||
KeyCombination kc2 = KeyCombination.valueOf("ctrl+r");
|
||||
reload_config.setAccelerator(kc2);
|
||||
reload_config.setOnAction(event -> {
|
||||
load_property();
|
||||
});
|
||||
|
||||
KeyCombination kc3 = KeyCombination.valueOf("ctrl+b");
|
||||
bucket_choose.setAccelerator(kc3);
|
||||
|
|
@ -205,6 +234,7 @@ public class MinioController {
|
|||
}
|
||||
|
||||
MinioUtils.upload_file(upload_file);
|
||||
reload();
|
||||
});
|
||||
|
||||
bucket_btn.setOnAction(event -> {
|
||||
|
|
@ -228,6 +258,7 @@ public class MinioController {
|
|||
return;
|
||||
}
|
||||
MinioUtils.createBucket(bucket_name.getText());
|
||||
load_bucket_list();
|
||||
});
|
||||
|
||||
load_property();
|
||||
|
|
@ -243,6 +274,7 @@ public class MinioController {
|
|||
}
|
||||
}
|
||||
});
|
||||
backet_list.setItems(backet_item_list);
|
||||
}
|
||||
|
||||
public void save_properties() {
|
||||
|
|
@ -299,6 +331,19 @@ public class MinioController {
|
|||
}
|
||||
}
|
||||
|
||||
public void load_bucket_list() {
|
||||
//刷新bucket列表
|
||||
//获取所有储存桶
|
||||
backet_item_list.clear();
|
||||
List<Bucket> buckets = MinioUtils.getAllBuckets();
|
||||
if (buckets.size() > 0) {
|
||||
for (Bucket bucket : buckets) {
|
||||
backet_item_list.add(bucket.name());
|
||||
}
|
||||
}
|
||||
this.backet_list.getSelectionModel().select(bucket_name.getText());
|
||||
}
|
||||
|
||||
public void load_property() {
|
||||
Properties prop = new Properties();
|
||||
File file = ResourceUtils.getPropertiesFile();
|
||||
|
|
@ -332,14 +377,7 @@ public class MinioController {
|
|||
}
|
||||
}
|
||||
|
||||
//获取所有储存桶
|
||||
List<Bucket> buckets = MinioUtils.getAllBuckets();
|
||||
if (buckets.size()>0){
|
||||
for (Bucket bucket : buckets) {
|
||||
backet_item_list.add(bucket.name());
|
||||
}
|
||||
}
|
||||
this.backet_list.setItems(backet_item_list);
|
||||
load_bucket_list();
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
@ -363,10 +401,11 @@ public class MinioController {
|
|||
AlertUtils.alert_warning("请选择bucket再试");
|
||||
return;
|
||||
}
|
||||
list.clear();
|
||||
String bucketName = obj.toString();
|
||||
List<BucketFile> bucketFiles = MinioUtils.getFileList(bucketName);
|
||||
if (bucketFiles.size() > 0) {
|
||||
list.clear();
|
||||
|
||||
list.addAll(bucketFiles);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue