zhangjinyang
2025-05-06 018447721dcb1668bb92ae23be50b5a1fef9387b
fix: s3 path problem. close #IC2YBG
2个文件已修改
21 ■■■■ 已修改文件
aiflowy-commons/aiflowy-common-file-storage/src/main/java/tech/aiflowy/common/filestorage/s3/S3Client.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiflowy-starter/src/main/resources/application.yml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiflowy-commons/aiflowy-common-file-storage/src/main/java/tech/aiflowy/common/filestorage/s3/S3Client.java
@@ -20,6 +20,7 @@
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.*;
import com.amazonaws.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
@@ -119,8 +120,14 @@
        byte[] content = file.getBytes();
        String name = file.getOriginalFilename();
        String path = generatePath(content, name);
        String baseUrl = properties.getEndpoint() + "/" + properties.getBucketName() + "/";
        if (StringUtils.hasValue(properties.getPrefix())) {
            path = properties.getPrefix() + "/" + path;
        }
        String completeUrl = baseUrl + path;
        upload(content, path, file.getContentType());
        return path;
        return completeUrl;
    }
    public static String generatePath(byte[] content, String originalName) throws Exception {
aiflowy-starter/src/main/resources/application.yml
@@ -21,10 +21,14 @@
aiflowy:
  storage:
    type: local
    endpoint: http://localhost:9000
    accessKey: minioadmin
    secretKey: minioadmin
    bucketName: mybucket
    s3:
      access-key: key
      secret-key: secret
      endpoint: your-endpoint
      region: your-region
      bucket-name: your-bucket-name
      access-policy: 2
      prefix: public
    local:
      root: ''
  ollama: