diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/AliYunOssAutoConfiguration.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/AliYunOssAutoConfiguration.java index 3f08e35..0e414fa 100644 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/AliYunOssAutoConfiguration.java +++ b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/AliYunOssAutoConfiguration.java @@ -22,8 +22,6 @@ import com.aliyun.oss.common.auth.STSAssumeRoleSessionCredentialsProvider; import com.aliyuncs.exceptions.ClientException; import com.fuhouyu.framework.common.utils.LoggerUtil; -import com.fuhouyu.framework.resource.properties.AliYunOssProperties; -import com.fuhouyu.framework.resource.properties.BaseOssResourceProperties; import com.fuhouyu.framework.resource.properties.ResourceProperties; import com.fuhouyu.framework.resource.service.ResourceService; import com.fuhouyu.framework.resource.service.impl.AliYunOssServiceImpl; @@ -31,7 +29,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -48,8 +46,9 @@ @ConditionalOnClass(OSS.class) @RequiredArgsConstructor @Slf4j -@EnableConfigurationProperties(AliYunOssProperties.class) @Configuration +@ConditionalOnProperty(prefix = ResourceProperties.PREFIX, + name = "upload-type", havingValue = "ali") public class AliYunOssAutoConfiguration implements InitializingBean { private final ResourceProperties resourceProperties; @@ -62,7 +61,7 @@ public class AliYunOssAutoConfiguration implements InitializingBean { */ @Bean public OSS ossClient() { - AliYunOssProperties ossConfig = resourceProperties.getAliOssConfig(); + ResourceProperties.AliYunOssProperties ossConfig = resourceProperties.getAliyunOss(); if (ossConfig.isEnableSts()) { STSAssumeRoleSessionCredentialsProvider credentialsProvider; @@ -96,8 +95,8 @@ public ResourceService resourceService(OSS oss) { @Override public void afterPropertiesSet() throws Exception { - BaseOssResourceProperties ossConfig = resourceProperties.getAliOssConfig(); - if (Objects.isNull(ossConfig)) { + ResourceProperties.AliYunOssProperties aliOssConfig = resourceProperties.getAliyunOss(); + if (Objects.isNull(aliOssConfig)) { throw new IllegalArgumentException("阿里云oss未设置相应的ak/sk"); } } diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceAutoConfiguration.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceConfiguration.java similarity index 56% rename from base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceAutoConfiguration.java rename to base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceConfiguration.java index 0467967..06336a9 100644 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceAutoConfiguration.java +++ b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/LocalFileResourceConfiguration.java @@ -16,12 +16,19 @@ package com.fuhouyu.framework.resource; +import com.fuhouyu.framework.common.utils.LoggerUtil; +import com.fuhouyu.framework.resource.properties.ResourceProperties; import com.fuhouyu.framework.resource.service.ResourceService; import com.fuhouyu.framework.resource.service.impl.LocalFileServiceImpl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.Objects; + /** *

* 本地文件资源自动装配类 @@ -31,8 +38,13 @@ * @since 2024/8/18 17:28 */ @Configuration(proxyBeanMethods = false) -public class LocalFileResourceAutoConfiguration { +@RequiredArgsConstructor +@Slf4j +@ConditionalOnProperty(prefix = ResourceProperties.PREFIX, + name = "upload-type", havingValue = "local") +public class LocalFileResourceConfiguration { + private final ResourceProperties resourceProperties; /** * 本地资源文件bean @@ -42,6 +54,14 @@ public class LocalFileResourceAutoConfiguration { @Bean @ConditionalOnMissingBean(ResourceService.class) public ResourceService localFileResourceService() { - return new LocalFileServiceImpl(); + String basePath; + if (Objects.isNull(resourceProperties.getLocalResource()) || + Objects.isNull(resourceProperties.getLocalResource().getBasePath())) { + basePath = System.getProperty("java.io.tmpdir"); + LoggerUtil.warn(log, "本地路径不存在,获取系统tmp路径:{}", basePath); + } else { + basePath = resourceProperties.getLocalResource().getBasePath(); + } + return new LocalFileServiceImpl(basePath); } } diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/ResourceAutoConfiguration.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/ResourceAutoConfiguration.java index ca866f6..a997c21 100644 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/ResourceAutoConfiguration.java +++ b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/ResourceAutoConfiguration.java @@ -29,7 +29,7 @@ * @author fuhouyu * @since 2024/8/16 18:36 */ -@Import({AliYunOssAutoConfiguration.class, LocalFileResourceAutoConfiguration.class}) +@Import({AliYunOssAutoConfiguration.class, LocalFileResourceConfiguration.class}) @EnableConfigurationProperties(ResourceProperties.class) @Configuration public class ResourceAutoConfiguration { diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/AliYunOssProperties.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/AliYunOssProperties.java deleted file mode 100644 index d1eee00..0000000 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/AliYunOssProperties.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2024-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.fuhouyu.framework.resource.properties; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - *

- * 阿里云配置项 - *

- * - * @author fuhouyu - * @since 2024/8/16 18:33 - */ -@ToString -@Getter -@Setter -public class AliYunOssProperties extends BaseOssResourceProperties { - - /** - * 区域. - */ - private String region; - - /** - * 是否启用sts,默认为false - */ - private boolean enableSts; - - /** - * sts相关配置,获取webToken必须要有该值. - */ - private StsConfig sts; - - /** - * stsConfig. - */ - @ToString - @Getter - @Setter - public static class StsConfig { - - private String endpoint; - - private String roleArn; - - private Integer expire; - - } - - -} diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/BaseOssResourceProperties.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/BaseOssResourceProperties.java deleted file mode 100644 index 4111889..0000000 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/BaseOssResourceProperties.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2024-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.fuhouyu.framework.resource.properties; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - *

- * 文件资源配置基类 - *

- * - * @author fuhouyu - * @since 2024/8/16 18:21 - */ -@ToString -@Getter -@Setter -public class BaseOssResourceProperties { - - private String endpoint; - - private String accessKey; - - private String secretKey; - -} diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/ResourceProperties.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/ResourceProperties.java index fab74a0..d846aeb 100644 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/ResourceProperties.java +++ b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/properties/ResourceProperties.java @@ -50,6 +50,77 @@ public class ResourceProperties { /** * 文件资源配置基类 */ - private AliYunOssProperties aliOssConfig; + private AliYunOssProperties aliyunOss; + /** + * 本地配置 + */ + private LocalResourceProperties localResource; + + @Getter + @Setter + @ToString + public static class LocalResourceProperties { + /** + * 根路径 + */ + private String basePath; + } + + @Getter + @Setter + @ToString + public static class CloudResourceProperties { + /** + * endpoint + */ + private String endpoint; + + /** + * ak + */ + private String accessKey; + + /** + * sk + */ + private String secretKey; + } + + + @Getter + @Setter + @ToString(callSuper = true) + public static class AliYunOssProperties extends CloudResourceProperties { + /** + * 区域. + */ + private String region; + + /** + * 是否启用sts,默认为false + */ + private boolean enableSts; + + /** + * sts相关配置,获取webToken必须要有该值. + */ + private StsConfig sts; + + /** + * stsConfig. + */ + @ToString + @Getter + @Setter + public static class StsConfig { + + private String endpoint; + + private String roleArn; + + private Integer expire; + + } + } } diff --git a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/service/impl/LocalFileServiceImpl.java b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/service/impl/LocalFileServiceImpl.java index da8e129..2f7db51 100644 --- a/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/service/impl/LocalFileServiceImpl.java +++ b/base-framework-resource-starter/src/main/java/com/fuhouyu/framework/resource/service/impl/LocalFileServiceImpl.java @@ -49,22 +49,27 @@ @Slf4j public class LocalFileServiceImpl implements ResourceService { - private static final int DEFAULT_BYTES_LENGTH = 8192; + private static final String TMP_DIRECT = System.getProperty("java.io.tmpdir"); - private static final String TMP_DIRECT = "/tmp"; + private static final int DEFAULT_BYTES_LENGTH = 8192; + private final String basePath; private static final String SPACER = ":"; - + public LocalFileServiceImpl(String basePath) { + this.basePath = basePath; + FileUtil.createDirectorIfNotExists(Paths.get(basePath)); + } @Override public GetResourceResult getFile(GetResourceRequest genericDownloadFileRequest) throws ResourceException { String bucketName = genericDownloadFileRequest.getBucketName(); String objectKey = genericDownloadFileRequest.getObjectKey(); - byte[] bytes = this.doDownloadFile(bucketName, objectKey, genericDownloadFileRequest.getRange()); + Path absPath = this.concatPath(bucketName, objectKey); + byte[] bytes = this.doDownloadFile(absPath, genericDownloadFileRequest.getRange()); GetResourceResult getResourceResult = new GetResourceResult(bucketName, objectKey); getResourceResult.setObjectContent(new ByteArrayInputStream(bytes)); - getResourceResult.setResourceMetadata(this.getFileResourceMetadata(Paths.get(bucketName, objectKey))); + getResourceResult.setResourceMetadata(this.getFileResourceMetadata(absPath)); return getResourceResult; } @@ -72,7 +77,7 @@ public GetResourceResult getFile(GetResourceRequest genericDownloadFileRequest) public ResourceMetadata getFile(GetResourceRequest genericDownloadFileRequest, File file) throws ResourceException { String bucketName = genericDownloadFileRequest.getBucketName(); String objectKey = genericDownloadFileRequest.getObjectKey(); - Path sourcePath = Paths.get(bucketName, objectKey); + Path sourcePath = this.concatPath(bucketName, objectKey); try { FileUtil.copyFile(sourcePath, file.toPath()); @@ -96,7 +101,7 @@ public PutResourceResult uploadFile(PutResourceRequest putResourceRequest) throw String bucketName = putResourceRequest.getBucketName(); File file = putResourceRequest.getFile(); - Path path = Paths.get(bucketName, objectKey); + Path path = this.concatPath(bucketName, objectKey); FileUtil.createDirectorIfNotExists(path.getParent()); FileUtil.deleteFileIfExists(path); @@ -174,7 +179,7 @@ public UploadCompleteMultipartResult completeMultipartUpload(UploadCompleteMulti } String bucketName = bucketNameAndObjectKey[0]; String objectKey = bucketNameAndObjectKey[1]; - Path targetPath = Paths.get(bucketName, objectKey); + Path targetPath = this.concatPath(bucketName, objectKey); FileUtil.deleteFileIfExists(targetPath); FileUtil.createDirectorIfNotExists(targetPath.getParent()); @@ -230,7 +235,7 @@ public void abortMultipartFileUpload(UploadAbortMultipartRequest uploadAbortMult @Override public boolean doesObjectExist(String bucketName, String objectKey) { - return Files.exists(Paths.get(bucketName, objectKey)); + return Files.exists(this.concatPath(bucketName, objectKey)); } @Override @@ -241,8 +246,8 @@ public ListResourceResult listFiles(ListResourceRequest listFileRequest) { @Override public CopyResourceResult copyFile(String sourceBucketName, String sourceObjectKey, String destBucketName, String destObjectKey) { try { - Path targetPath = Paths.get(destBucketName, destBucketName); - FileUtil.copyFile(Paths.get(sourceBucketName, sourceObjectKey), + Path targetPath = this.concatPath(destBucketName, destObjectKey); + FileUtil.copyFile(this.concatPath(sourceBucketName, sourceObjectKey), targetPath); String etag = FileUtil.calculateFileDigest(targetPath, this.getMd5MessageDigest()); FileUtil.setFileAttribute(targetPath, @@ -260,30 +265,26 @@ public CopyResourceResult copyFile(String sourceBucketName, String sourceObjectK @Override public void deleteFile(String bucketName, String objectKey) { - FileUtil.deleteFileIfExists(Paths.get(bucketName, objectKey)); + FileUtil.deleteFileIfExists(this.concatPath(bucketName, objectKey)); } /** * 执行文件下载 * - * @param bucketName 桶名 - * @param objectKey 对象key - * @param ranges 是否范围下载,如果为空,则下载所有的文件 + * @param path 文件路径 + * @param ranges 是否范围下载,如果为空,则下载所有的文件 * @return 文件下载的字节数组 * @throws ResourceException 资源异常 */ - private byte[] doDownloadFile(String bucketName, - String objectKey, - long[] ranges) throws ResourceException { + private byte[] doDownloadFile(Path path, long[] ranges) throws ResourceException { - try (FileChannel fileChannel = FileChannel.open(Paths.get(bucketName, objectKey), StandardOpenOption.READ)) { + try (FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.READ)) { if (Objects.nonNull(ranges)) { return this.rangesDownload(ranges, fileChannel); } - ByteBuffer byteBuffer = ByteBuffer.allocate(DEFAULT_BYTES_LENGTH); byte[] bytes = new byte[(int) fileChannel.size()]; - this.doReadFileToBytes(fileChannel, byteBuffer, bytes); + this.doReadFileToBytes(fileChannel, bytes); return bytes; } catch (IOException e) { throw new ResourceException(e.getMessage(), e); @@ -306,9 +307,8 @@ private byte[] rangesDownload(long[] ranges, throw new IllegalArgumentException("文件资源范围下载取值不正常"); } - ByteBuffer byteBuffer = ByteBuffer.allocate((int) totalSize); byte[] bytes = new byte[(int) totalSize]; - this.doReadFileToBytes(fileChannel, byteBuffer, bytes); + this.doReadFileToBytes(fileChannel, bytes); return bytes; } @@ -316,24 +316,18 @@ private byte[] rangesDownload(long[] ranges, * 读取文件字节流 * * @param fileChannel 文件通道 - * @param byteBuffer byteBuffer - * @param bytes 字节数组 + * @param bytes 字节数组 * @throws IOException io异常 */ - private void doReadFileToBytes(FileChannel fileChannel, - ByteBuffer byteBuffer, - byte[] bytes) throws IOException { + private void doReadFileToBytes(FileChannel fileChannel, byte[] bytes) throws IOException { int position = 0; - int readLength = byteBuffer.capacity(); int totalFileSize = (int) fileChannel.size(); + ByteBuffer byteBuffer = ByteBuffer.allocate(DEFAULT_BYTES_LENGTH); while ((fileChannel.read(byteBuffer)) > 0) { byteBuffer.flip(); - if (position + readLength > totalFileSize) { - readLength = totalFileSize - position; - } - byteBuffer.get(bytes, Math.min(position, totalFileSize), - readLength); - position += readLength; + int remainingBytes = Math.min(byteBuffer.remaining(), totalFileSize - position); + byteBuffer.get(bytes, position, remainingBytes); + position += remainingBytes; byteBuffer.clear(); } } @@ -367,8 +361,8 @@ private ResourceMetadata getFileResourceMetadata(Path path) throws ResourceExcep * @param tmpUploadFilePath 分片文件路径 * @param targetPath 目标路径 * @param uploadId 上传的文件id - * @throws ResourceException 资源异常 * @return etag + * @throws ResourceException 资源异常 */ public String mergeFile(Path tmpUploadFilePath, Path targetPath, String uploadId) throws ResourceException { try { @@ -445,4 +439,15 @@ private MessageDigest getMd5MessageDigest() { throw new IllegalArgumentException("No Such Algorithm" + e.getMessage(), e); } } + + /** + * 拼接路径 + * + * @param paths 路径数组 + * @return 拼接后的路径 + */ + private Path concatPath(String... paths) { + return Paths.get(basePath, paths); + } + } diff --git a/base-framework-resource-starter/src/test/java/com/fuhouyu/framework/resource/ResourceServiceTest.java b/base-framework-resource-starter/src/test/java/com/fuhouyu/framework/resource/ResourceServiceTest.java index c5a9adf..ec65745 100644 --- a/base-framework-resource-starter/src/test/java/com/fuhouyu/framework/resource/ResourceServiceTest.java +++ b/base-framework-resource-starter/src/test/java/com/fuhouyu/framework/resource/ResourceServiceTest.java @@ -22,6 +22,7 @@ import com.fuhouyu.framework.resource.model.*; import com.fuhouyu.framework.resource.service.ResourceService; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -30,6 +31,8 @@ import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.UUID; /** *

@@ -40,70 +43,74 @@ * @since 2024/8/16 20:24 */ @SpringBootTest(classes = { -// ResourceAutoConfigure.class, - LocalFileResourceAutoConfiguration.class + ResourceAutoConfiguration.class, +// LocalFileResourceConfiguration.class }) @TestPropertySource(locations = {"classpath:application.yaml"}) class ResourceServiceTest { - private static final String BUCKET_NAME = "/tmp"; - private static final String LOCAL_FILE_PARENT = "./"; + private static final String BUCKET_NAME = "test/upload"; + + private static final String DOWNLOAD_PATH + = System.getProperty("java.io.tmpdir") + File.separator + "download"; + private static final InputStream FILE_INPUT_STREAM = - new ByteArrayInputStream("test_file".getBytes(StandardCharsets.UTF_8)); - private final String objectKey = "text.txt"; + new ByteArrayInputStream(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8)); + + private static final String OBJECT_KEY = "text.txt"; @Autowired private ResourceService resourceService; + + @BeforeAll + static void setUp() { + FileUtil.createDirectorIfNotExists(Paths.get(BUCKET_NAME)); + FileUtil.createDirectorIfNotExists(Paths.get(DOWNLOAD_PATH)); + } + @Test void testResourceUpload() throws ResourceException { PutResourceResult putResourceResult = - resourceService.uploadFile(new PutResourceRequest(BUCKET_NAME, objectKey, FILE_INPUT_STREAM)); + resourceService.uploadFile(new PutResourceRequest(BUCKET_NAME, OBJECT_KEY, FILE_INPUT_STREAM)); Assertions.assertNotNull(putResourceResult, "文件上传失败"); } @Test void testResourceDownload() throws ResourceException { - String filePath = LOCAL_FILE_PARENT + "resource_download.xml"; + String filePath = DOWNLOAD_PATH + File.separator + OBJECT_KEY; DownloadResourceResult downloadResourceResult = - resourceService.downloadFile(new DownloadResourceRequest("./", "pom.xml", filePath, 1000)); + resourceService.downloadFile(new DownloadResourceRequest(BUCKET_NAME, OBJECT_KEY, filePath, 1000)); Assertions.assertNotNull(downloadResourceResult, "文件下载失败"); FileUtil.deleteFileIfExists(Path.of(filePath)); } - @Test - void testResourceDelete() throws ResourceException { - resourceService.deleteFile(BUCKET_NAME, objectKey); - Assertions.assertTrue((!resourceService.doesObjectExist(BUCKET_NAME, objectKey)), "文件未被删除"); - } - @Test void testGetFile() throws ResourceException { GetResourceRequest getResourceRequest = new GetResourceRequest(BUCKET_NAME, - objectKey); + OBJECT_KEY); GetResourceResult getResourceResult = resourceService.getFile(getResourceRequest); InputStream objectContent = getResourceResult.getObjectContent(); Assertions.assertNotNull(objectContent, "资源文件下载失败"); // 测试下载文件的写入 - String localFilePath = LOCAL_FILE_PARENT + "get_file.txt"; + String localFilePath = DOWNLOAD_PATH + File.separator + OBJECT_KEY; try (objectContent; FileOutputStream fileOutputStream = new FileOutputStream(localFilePath)) { fileOutputStream.write(objectContent.readAllBytes()); } catch (IOException e) { throw new RuntimeException(e); } - FileUtil.deleteFileIfExists(Path.of(localFilePath)); } @Test void testUploadFile() throws ResourceException { - PutResourceRequest putResourceRequest = new PutResourceRequest(BUCKET_NAME, objectKey, FILE_INPUT_STREAM); + PutResourceRequest putResourceRequest = new PutResourceRequest(BUCKET_NAME, OBJECT_KEY, FILE_INPUT_STREAM); PutResourceResult putResourceResult = this.resourceService.uploadFile(putResourceRequest); Assertions.assertNotNull(putResourceResult, "返回结果为空"); - GetResourceRequest getResourceRequest = new GetResourceRequest(BUCKET_NAME, objectKey); + GetResourceRequest getResourceRequest = new GetResourceRequest(BUCKET_NAME, OBJECT_KEY); GetResourceResult getResourceResult = resourceService.getFile(getResourceRequest); ResourceMetadata resourceMetadata = getResourceResult.getResourceMetadata(); Assertions.assertNotNull(resourceMetadata, "文件元数据为空"); @@ -112,10 +119,10 @@ void testUploadFile() throws ResourceException { @Test void testInitUploadId() throws ResourceException, IOException { - String localFilePath = LOCAL_FILE_PARENT + "pom.xml"; + String localFilePath = "pom.xml"; InitiateUploadMultipartRequest initiateUploadMultipartRequest = new InitiateUploadMultipartRequest(BUCKET_NAME, - objectKey); + OBJECT_KEY); InitiateUploadMultipartResult initiateUploadMultipartResult = resourceService.initiateMultipartUpload(initiateUploadMultipartRequest); Assertions.assertNotNull(initiateUploadMultipartResult, "初始化上传id 返回的结果为空"); diff --git a/base-framework-resource-starter/src/main/resources/application.yaml b/base-framework-resource-starter/src/test/resources/application.yaml similarity index 100% rename from base-framework-resource-starter/src/main/resources/application.yaml rename to base-framework-resource-starter/src/test/resources/application.yaml diff --git a/pom.xml b/pom.xml index efa148c..ca09880 100644 --- a/pom.xml +++ b/pom.xml @@ -77,10 +77,10 @@ false - 4.0.0-beta-1 - 4.0.0-beta-1 - 4.0.0-beta-1 - 4.0.0-beta-1 + 3.4.0 + 3.13.0 + 3.3.1 + 3.4.2 3.3.2 2.17.1 @@ -189,13 +189,6 @@ kryo5 ${kryo5.version} - - com.fasterxml.jackson - jackson-bom - ${jackson-bom.version} - pom - import - com.aliyun.oss aliyun-sdk-oss