From 6d95eeed3cf8571f4e045f4c88bcc6685ca19ec9 Mon Sep 17 00:00:00 2001 From: zhangmeng <1334717033@qq.com> Date: Mon, 7 Jul 2025 15:32:10 +0800 Subject: [PATCH] =?UTF-8?q?2025=E5=B9=B47=E6=9C=887=E6=97=A515:32:03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- minio.properties | 3 - pom.xml | 78 ++----- .../zhangmeng/minio/MiniToolsApplication.java | 9 +- src/main/java/com/zhangmeng/minio/Start.java | 15 -- .../minio/controller/ConfigController.java | 22 ++ .../minio/controller/MinioController.java | 103 ++++----- .../com/zhangmeng/minio/model/Config.java | 47 ++++ .../com/zhangmeng/minio/utils/MinioUtils.java | 202 +++++++----------- .../zhangmeng/minio/utils/ResourceUtils.java | 3 +- src/main/java/module-info.java | 17 ++ src/main/resources/fxml/config.fxml | 47 ++-- src/main/resources/fxml/main.fxml | 33 ++- src/main/resources/minio.properties | 3 - 13 files changed, 300 insertions(+), 282 deletions(-) delete mode 100644 minio.properties delete mode 100644 src/main/java/com/zhangmeng/minio/Start.java create mode 100644 src/main/java/com/zhangmeng/minio/controller/ConfigController.java create mode 100644 src/main/java/com/zhangmeng/minio/model/Config.java create mode 100644 src/main/java/module-info.java delete mode 100644 src/main/resources/minio.properties diff --git a/minio.properties b/minio.properties deleted file mode 100644 index 9872f70..0000000 --- a/minio.properties +++ /dev/null @@ -1,3 +0,0 @@ -endpoint = http://192.168.1.254:9000 -accessKey = minioadmin -secretKey = minioadmin \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9ec2759..ad9ea47 100644 --- a/pom.xml +++ b/pom.xml @@ -18,25 +18,7 @@ io.minio minio - 8.5.7 - - - - com.squareup.okhttp3 - okhttp - 4.8.1 - - - - org.projectlombok - lombok - 1.18.30 - - - - org.apache.commons - commons-lang3 - 3.11 + 8.5.17 @@ -83,59 +65,41 @@ - com.github.leewyatt - rxcontrols - - 11.0.2 + com.alibaba.fastjson2 + fastjson2 + 2.0.49 - - com.fasterxml.jackson.core - jackson-core - 2.16.1 - - - log4j - log4j - 1.2.17 - - - org.apache.tika - tika-core - 1.27 - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 + maven-compiler-plugin + 3.11.0 - - - true - lib/ - com.zhangmeng.minio.MiniToolsApplication - - + 17 + 17 - org.apache.maven.plugins - maven-dependency-plugin - 3.1.1 + org.openjfx + javafx-maven-plugin + 0.0.8 - copy-dependencies - package - - copy-dependencies - + + default-cli - ${project.build.directory}/lib + com.zhangmeng.minio.MiniToolsApplication + + app + app + app + true + true + true diff --git a/src/main/java/com/zhangmeng/minio/MiniToolsApplication.java b/src/main/java/com/zhangmeng/minio/MiniToolsApplication.java index 6a3755c..1d90cc3 100644 --- a/src/main/java/com/zhangmeng/minio/MiniToolsApplication.java +++ b/src/main/java/com/zhangmeng/minio/MiniToolsApplication.java @@ -5,6 +5,7 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; @@ -18,9 +19,15 @@ public class MiniToolsApplication extends Application { @Override public void start(Stage primaryStage) throws Exception { MinioUtils.objectMap.put(MinioUtils.primaryStage,primaryStage); - Parent root = FXMLLoader.load(this.getClass().getResource("/fxml/main.fxml")); + AnchorPane root = FXMLLoader.load(this.getClass().getResource("/fxml/main.fxml")); primaryStage.setScene(new Scene(root)); primaryStage.setTitle("javafx minio 工具"); primaryStage.show(); } + + public static void main(String[] args) { + launch(args); + } + + } diff --git a/src/main/java/com/zhangmeng/minio/Start.java b/src/main/java/com/zhangmeng/minio/Start.java deleted file mode 100644 index 33964b1..0000000 --- a/src/main/java/com/zhangmeng/minio/Start.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.zhangmeng.minio; - -import javafx.application.Application; - -/** - * @author zhangmeng - * @version 1.0 - * @date 2024-03-11 16:44 - */ -public class Start { - - public static void main(String[] args) { - Application.launch(MiniToolsApplication.class,args); - } -} diff --git a/src/main/java/com/zhangmeng/minio/controller/ConfigController.java b/src/main/java/com/zhangmeng/minio/controller/ConfigController.java new file mode 100644 index 0000000..cd1a7eb --- /dev/null +++ b/src/main/java/com/zhangmeng/minio/controller/ConfigController.java @@ -0,0 +1,22 @@ +package com.zhangmeng.minio.controller; + +import javafx.event.ActionEvent; +import javafx.scene.control.TextField; + +public class ConfigController { + public TextField url; + public TextField username; + public TextField password; + + public void initialize() { + + } + + public void handleSave(ActionEvent actionEvent) { + + } + + public void handleCancel(ActionEvent actionEvent) { + + } +} diff --git a/src/main/java/com/zhangmeng/minio/controller/MinioController.java b/src/main/java/com/zhangmeng/minio/controller/MinioController.java index 4392d3b..feaf4ca 100644 --- a/src/main/java/com/zhangmeng/minio/controller/MinioController.java +++ b/src/main/java/com/zhangmeng/minio/controller/MinioController.java @@ -1,6 +1,9 @@ package com.zhangmeng.minio.controller; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONPObject; import com.zhangmeng.minio.model.BucketFile; +import com.zhangmeng.minio.model.Config; import com.zhangmeng.minio.utils.AlertUtils; import com.zhangmeng.minio.utils.MinioUtils; import com.zhangmeng.minio.utils.ResourceUtils; @@ -14,10 +17,12 @@ import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCodeCombination; import javafx.scene.input.KeyCombination; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -29,9 +34,11 @@ import java.awt.datatransfer.Transferable; import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.List; import java.util.Properties; + /** * @author zhangmeng * @version 1.0 @@ -68,18 +75,12 @@ public class MinioController { @FXML public Button bucket_btn; - @FXML public TextField endpoint; - @FXML public TextField accessKey; - @FXML public TextField secretKey; - @FXML - public Button save_config; - @FXML public ComboBox backet_list; @@ -98,11 +99,18 @@ public class MinioController { @FXML public TableColumn file_bucket; + public ImageView preview; + private File upload_file; @FXML public void initialize() { + + endpoint = new TextField(); + accessKey = new TextField(); + secretKey = new TextField(); + tableview.setItems(list); file_name.setCellValueFactory(new PropertyValueFactory("fileName")); file_size.setCellValueFactory(new PropertyValueFactory("size")); @@ -122,13 +130,10 @@ public class MinioController { BucketFile selectedItem = tableview.getSelectionModel().getSelectedItem(); - // 获取系统剪贴板 Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - // 创建一个 StringSelection 对象,该对象封装了要复制的文本 Transferable transferableText = new StringSelection(selectedItem.getUrl()); - // 将文本内容设置到剪贴板 clipboard.setContents(transferableText, null); @@ -154,7 +159,7 @@ public class MinioController { @Override public void changed(ObservableValue observable, BucketFile oldValue, BucketFile newValue) { if (newValue != null) { - System.out.println(newValue.getFileName()); + loadPreview(backet_list.getSelectionModel().getSelectedItem(), newValue.getFileName()); } } }); @@ -166,19 +171,35 @@ public class MinioController { FileInputStream fileInputStream = null; try { FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("/fxml/config.fxml")); - AnchorPane root = fxmlLoader.load(); + VBox root = fxmlLoader.load(); ObservableMap namespace = fxmlLoader.getNamespace(); - TextArea text_area = (TextArea) namespace.get("text_area"); - Button save_p = (Button) namespace.get("save_p"); + TextField url = (TextField) namespace.get("url"); + TextField username = (TextField) namespace.get("username"); + TextField password = (TextField) namespace.get("password"); + Button save = (Button) namespace.get("save"); + Button cancel = (Button) namespace.get("cancel"); + fileInputStream = new FileInputStream(ResourceUtils.getPropertiesFile()); byte[] bytes = fileInputStream.readAllBytes(); - text_area.setText(new String(bytes, StandardCharsets.UTF_8)); - Stage stage = AlertUtils.alert("minio 配置文件", root, 600, 410, (Stage) MinioUtils.objectMap.get(MinioUtils.primaryStage)); - save_p.setOnAction(event1 -> { + String json = new String(bytes, StandardCharsets.UTF_8); + if (json != null && !json.equals("")) { + Config parseObject = JSON.parseObject(json, Config.class); + endpoint.setText(parseObject.getEndpoint()); + url.setText(parseObject.getEndpoint()); + accessKey.setText(parseObject.getAccessKey()); + username.setText(parseObject.getAccessKey()); + secretKey.setText(parseObject.getSecretKey()); + password.setText(parseObject.getSecretKey()); + } + + Stage stage = AlertUtils.alert("minio 配置文件", root, 600, 180, (Stage) MinioUtils.objectMap.get(MinioUtils.primaryStage)); + save.setOnAction(event1 -> { stage.close(); try { FileWriter fileWriter = new FileWriter(ResourceUtils.getPropertiesFile()); - fileWriter.write(text_area.getText()); + Config config = new Config(endpoint.getText(), accessKey.getText(), secretKey.getText()); + String json_config = JSON.toJSONString(config); + fileWriter.write(json_config); fileWriter.flush(); fileWriter.close(); load_property(); @@ -232,9 +253,9 @@ public class MinioController { AlertUtils.alert_warning("请选择上传的文件后再试!"); return; } - MinioUtils.upload_file(upload_file); - reload(); + String objectUrl = MinioUtils.getPresignedObjectUrl(bucket_name.getText(), upload_file.getName()); + preview.setImage(new javafx.scene.image.Image(objectUrl)); }); bucket_btn.setOnAction(event -> { @@ -261,14 +282,10 @@ public class MinioController { load_bucket_list(); }); - load_property(); - - save_config.setOnAction(event -> save_properties()); - backet_list.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, String oldValue, String newValue) { - if (newValue != null) { + if (newValue != null && !newValue.equals("")) { MinioUtils.objectMap.put(MinioUtils.current_bucket, newValue); reload(); } @@ -331,6 +348,11 @@ public class MinioController { } } + private void loadPreview(String bucketName, String objectName){ + String objectUrl = MinioUtils.getPresignedObjectUrl(bucketName, objectName); + preview.setImage(new javafx.scene.image.Image(objectUrl)); + } + public void load_bucket_list() { //刷新bucket列表 //获取所有储存桶 @@ -345,38 +367,21 @@ public class MinioController { } public void load_property() { - Properties prop = new Properties(); File file = ResourceUtils.getPropertiesFile(); if (file != null) { - InputStream input = null; try { - input = new FileInputStream(file); - // load a properties file - prop.load(input); - // get the property value and print it out - String endpoint = prop.getProperty("endpoint"); - this.endpoint.setText(endpoint); - String accessKey = prop.getProperty("accessKey"); - this.accessKey.setText(accessKey); - String secretKey = prop.getProperty("secretKey"); - this.secretKey.setText(secretKey); - - MinioUtils.objectMap.put("endpoint", endpoint); - MinioUtils.objectMap.put("accessKey", accessKey); - MinioUtils.objectMap.put("secretKey", secretKey); + String json = Files.readString(file.toPath()); + Config config = JSON.parseObject(json, Config.class); + this.endpoint.setText(config.getEndpoint()); + this.accessKey.setText(config.getAccessKey()); + this.secretKey.setText(config.getSecretKey()); + MinioUtils.objectMap.put("endpoint", config.getEndpoint()); + MinioUtils.objectMap.put("accessKey", config.getAccessKey()); + MinioUtils.objectMap.put("secretKey", config.getSecretKey()); } catch (IOException ex) { ex.printStackTrace(); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } } } - load_bucket_list(); } diff --git a/src/main/java/com/zhangmeng/minio/model/Config.java b/src/main/java/com/zhangmeng/minio/model/Config.java new file mode 100644 index 0000000..f0c7f36 --- /dev/null +++ b/src/main/java/com/zhangmeng/minio/model/Config.java @@ -0,0 +1,47 @@ +package com.zhangmeng.minio.model; + +public class Config { + + private String endpoint; + private String accessKey; + private String secretKey; + + public Config(String endpoint, String accessKey, String secretKey) { + this.endpoint = endpoint; + this.accessKey = accessKey; + this.secretKey = secretKey; + } + + @Override + public String toString() { + return "Config{" + + "endpoint='" + endpoint + '\'' + + ", accessKey='" + accessKey + '\'' + + ", secretKey='" + secretKey + '\'' + + '}'; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } +} diff --git a/src/main/java/com/zhangmeng/minio/utils/MinioUtils.java b/src/main/java/com/zhangmeng/minio/utils/MinioUtils.java index 067312e..8d88222 100644 --- a/src/main/java/com/zhangmeng/minio/utils/MinioUtils.java +++ b/src/main/java/com/zhangmeng/minio/utils/MinioUtils.java @@ -7,10 +7,7 @@ import io.minio.http.Method; import io.minio.messages.Bucket; import io.minio.messages.Item; import javafx.application.Platform; -import javafx.scene.control.TextField; -import org.apache.commons.lang3.StringUtils; -import org.apache.tika.Tika; -import org.apache.tika.exception.TikaException; + import java.io.*; import java.security.InvalidKeyException; @@ -32,8 +29,6 @@ public class MinioUtils { private static MinioClient minioClient = null; - - public static Map objectMap = new HashMap<>(); public static String current_bucket = "current_bucket"; public static String primaryStage = "primaryStage"; @@ -65,6 +60,7 @@ public class MinioUtils { return null; } minioClient = MinioClient.builder().endpoint(endpoint.toString()).credentials(accessKey.toString(), secretKey.toString()).build(); + } return minioClient; } @@ -77,23 +73,7 @@ public class MinioUtils { public static List getAllBuckets() { try { return getDefault().listBuckets(); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (InternalException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (ServerException e) { - e.printStackTrace(); - } catch (XmlParserException e) { + } catch (ErrorResponseException | InsufficientDataException | InvalidKeyException | InternalException | InvalidResponseException | IOException | NoSuchAlgorithmException | ServerException | XmlParserException e) { e.printStackTrace(); } return null; @@ -109,23 +89,7 @@ public class MinioUtils { if (!bucketExists(bucketName)) { try { getDefault().makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (InternalException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (ServerException e) { - e.printStackTrace(); - } catch (XmlParserException e) { + } catch (ErrorResponseException | InternalException | InvalidKeyException | InvalidResponseException | IOException | NoSuchAlgorithmException | XmlParserException | ServerException | InsufficientDataException e) { e.printStackTrace(); } }else { @@ -144,23 +108,7 @@ public class MinioUtils { public static Boolean bucketExists(String bucketName) { try { return getDefault().bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (InternalException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (ServerException e) { - e.printStackTrace(); - } catch (XmlParserException e) { + } catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidResponseException | NoSuchAlgorithmException | XmlParserException | ServerException | IOException | InvalidKeyException e) { e.printStackTrace(); } return null; @@ -192,23 +140,9 @@ public class MinioUtils { Item item = null; try { item = o.get(); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (InternalException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (ServerException e) { - e.printStackTrace(); - } catch (XmlParserException e) { + } catch (ErrorResponseException | InsufficientDataException | InvalidKeyException | + InvalidResponseException | InternalException | IOException | NoSuchAlgorithmException | + ServerException | XmlParserException e) { e.printStackTrace(); } list.add(item); @@ -231,23 +165,7 @@ public class MinioUtils { .method(Method.GET).build(); try { return getDefault() .getPresignedObjectUrl(args); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (InternalException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (XmlParserException e) { - e.printStackTrace(); - } catch (ServerException e) { + } catch (ErrorResponseException | InsufficientDataException | InvalidKeyException | InvalidResponseException | NoSuchAlgorithmException | ServerException | XmlParserException | IOException | InternalException e) { e.printStackTrace(); } return null; @@ -275,7 +193,7 @@ public class MinioUtils { public static void upload_file(File file){ //文件名 String fileName = file.getName(); - String newFileName = System.currentTimeMillis() + "." + StringUtils.substringAfterLast(fileName, "."); + String newFileName = System.currentTimeMillis() + "." + getFileExtension(fileName); String contentType = getContentType(file); String bucketName = objectMap.get(current_bucket).toString(); if (bucketName == null){ @@ -285,6 +203,77 @@ public class MinioUtils { uploadFile(bucketName, file, newFileName, contentType); } + public static String getContentType(File file) { + String fileName = file.getName(); + String extension = getFileExtension(fileName).toLowerCase(); + return switch (extension) { + case "jpg", "jpeg" -> "image/jpeg"; + case "png" -> "image/png"; + case "mp4" -> "video/mp4"; + case "gif" -> "image/gif"; + case "txt" -> "text/plain"; + case "pdf" -> "application/pdf"; + case "doc" -> "application/msword"; + case "docx" -> "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + case "xls" -> "application/vnd.ms-excel"; + case "xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + case "ppt" -> "application/vnd.ms-powerpoint"; + case "pptx" -> "application/vnd.openxmlformats-officedocument.presentationml.presentation"; + case "zip" -> "application/zip"; + case "tar" -> "application/x-tar"; + case "json" -> "application/json"; + case "html" -> "text/html"; + case "css" -> "text/css"; + case "js" -> "application/javascript"; + case "mp3" -> "audio/mp3"; + case "wav" -> "audio/wav"; + case "flac" -> "audio/flac"; + case "aac" -> "audio/aac"; + case "ogg" -> "audio/ogg"; + case "avi" -> "video/avi"; + case "mov" -> "video/quicktime"; + case "wmv" -> "video/x-ms-wmv"; + case "mkv" -> "video/x-matroska"; + case "flv" -> "video/x-flv"; + case "swf" -> "application/x-shockwave-flash"; + case "psd" -> "image/vnd.adobe.photoshop"; + case "ai" -> "application/postscript"; + case "eps" -> "application/postscript"; + case "ps" -> "application/postscript"; + case "svg" -> "image/svg+xml"; + case "tif" -> "image/tiff"; + case "tiff" -> "image/tiff"; + case "ico" -> "image/x-icon"; + case "md" -> "text/markdown"; + case "yaml" -> "text/yaml"; + case "yml" -> "text/yaml"; + case "xml" -> "text/xml"; + case "csv" -> "text/csv"; + case "tsv" -> "text/tab-separated-values"; + case "jsonl" -> "application/json-seq"; + case "bin" -> "application/octet-stream"; + case "exe" -> "application/octet-stream"; + case "dll" -> "application/octet-stream"; + case "so" -> "application/octet-stream"; + case "class" -> "application/octet-stream"; + case "war" -> "application/octet-stream"; + case "ear" -> "application/octet-stream"; + case "rar" -> "application/octet-stream"; + case "gz" -> "application/gzip"; + default -> "application/octet-stream"; + }; + } + // 原生 Java 的等价方法 + public static String getFileExtension(String fileName) { + if (fileName == null) return ""; + int lastDotIndex = fileName.lastIndexOf('.'); + // 判断没有点,或者点是第一个字符(例如 ".gitignore") + if (lastDotIndex == -1 || lastDotIndex == 0) { + return fileName; + } + return fileName.substring(lastDotIndex + 1); + } + /** * 使用MultipartFile进行文件上传 * @@ -305,23 +294,7 @@ public class MinioUtils { .contentType(contentType) .stream(inputStream,inputStream.available(), -1) .build()); - } catch (IOException e) { - e.printStackTrace(); - } catch (ServerException e) { - e.printStackTrace(); - } catch (InsufficientDataException e) { - e.printStackTrace(); - } catch (ErrorResponseException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (InvalidResponseException e) { - e.printStackTrace(); - } catch (XmlParserException e) { - e.printStackTrace(); - } catch (InternalException e) { + } catch (IOException | XmlParserException | InternalException | InvalidKeyException | ErrorResponseException | ServerException | InsufficientDataException | InvalidResponseException | NoSuchAlgorithmException e) { e.printStackTrace(); } finally { if (inputStream != null){ @@ -334,15 +307,4 @@ public class MinioUtils { } return null; } - - - public static String getContentType(File file){ - Tika tika = new Tika(); - try { - return tika.detect(file); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } } diff --git a/src/main/java/com/zhangmeng/minio/utils/ResourceUtils.java b/src/main/java/com/zhangmeng/minio/utils/ResourceUtils.java index 8cfa524..5cbd429 100644 --- a/src/main/java/com/zhangmeng/minio/utils/ResourceUtils.java +++ b/src/main/java/com/zhangmeng/minio/utils/ResourceUtils.java @@ -11,14 +11,13 @@ import java.io.IOException; */ public class ResourceUtils { - /** * Properties prop = new Properties(); * URL resource = this.getClass().getResource("/minio.properties"); */ public static File getPropertiesFile(){ - String file_path = System.getProperty("user.dir") + "/minio.properties"; + String file_path = System.getProperty("user.dir") + "/minio.json"; File file = new File(file_path); if (!file.exists()){ try { diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..b6471e9 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,17 @@ +module javafx.tools.minio { + + requires javafx.controls; + requires javafx.fxml; + requires java.sql; + requires java.datatransfer; + requires java.desktop; + requires minio; + requires com.fasterxml.jackson.core; + requires com.alibaba.fastjson2; + + opens com.zhangmeng.minio to javafx.graphics; + opens com.zhangmeng.minio.controller to javafx.fxml; + + exports com.zhangmeng.minio.controller; + exports com.zhangmeng.minio.model; +} \ No newline at end of file diff --git a/src/main/resources/fxml/config.fxml b/src/main/resources/fxml/config.fxml index edbd63f..766b50f 100644 --- a/src/main/resources/fxml/config.fxml +++ b/src/main/resources/fxml/config.fxml @@ -1,17 +1,36 @@ - - - - + + + - - -