Skip to content

Commit

Permalink
Merge pull request #201 from dromara/dev
Browse files Browse the repository at this point in the history
Release:2.1.0
  • Loading branch information
1171736840 authored Jan 19, 2024
2 parents 933683a + b387cdf commit b568c05
Show file tree
Hide file tree
Showing 221 changed files with 17,365 additions and 3,347 deletions.
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ hs_err_pid*

# maven ignore
target/
.mvn/
bin/
.sts4-cache/
*.versionsBackup
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# eclipse ignore
.settings/
Expand Down
1 change: 1 addition & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-XX:+UseG1GC -Xmx2g -Xms2g
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-s=.mvn/settings.xml
-Dmaven.test.skip=true
13 changes: 13 additions & 0 deletions .mvn/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<mirrors>
<mirror>
<id>aliyun</id>
<name>Aliyun Maven Mirror</name>
<url>https://maven.aliyun.com/repository/central</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
117 changes: 117 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2007-present 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
*
* http://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.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
2 changes: 2 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
4 changes: 4 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
maven=3.8.1
java=8.0.302-open
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</a>
<br />
<a href='https://jq.qq.com/?_wv=1027&k=eGfeNqka'>
<img src='https://img.shields.io/badge/QQ%E7%BE%A4-515706495-orange' alt='' />
<img src='https://img.shields.io/badge/QQ%E7%BE%A4-515706495-orange' alt='515706495' />
</a>
</p>

Expand All @@ -36,7 +36,7 @@
### 📚简介

一行代码将文件存储到本地、FTP、SFTP、WebDAV、阿里云 OSS、华为云 OBS、七牛云 Kodo、腾讯云 COS、百度云 BOS、又拍云 USS、MinIO、
Amazon S3、GoogleCloud Storage、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动 云EOS、沃云 OSS、
Amazon S3、GoogleCloud Storage、FastDFS、 Azure Blob Storage、Cloudflare R2、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动 云EOS、沃云 OSS、
网易数帆 NOS、Ucloud US3、青云 QingStor、平安云 OBS、首云 OSS、IBM COS、其它兼容 S3 协议的存储平台。查看 [所有支持的存储平台](https://x-file-storage.xuyanwu.cn/#/存储平台)

💡 通过 WebDAV 连接到 Alist 后,可以使用百度网盘、天翼云盘、阿里云盘、迅雷网盘等常见存储服务,查看 [Alist 支持的存储平台](https://alist-doc.nn.ci/docs/webdav)
Expand All @@ -51,6 +51,8 @@ Gitee:https://gitee.com/dromara/x-file-storage

这里是简要的更新记录,查看 [详细的更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录)

`2.1.0` 修复大量问题,新增存储平台 FastDFS 和 Azure Blob Storage,新增复制、移动(重命名)文件,手动分片上传(断点续传)和计算哈希等功能,详情查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_210)
<br />
`2.0.0` 捐赠至 [dromara](https://dromara.org/zh) 开源社区,更改项目名、包名,优化项目结构、支持 Metadata 元数据等,从旧版升级需要注意,详情查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_200)
<br />
`1.0.3` 修复了 FileStorageClientFactory 未自动加载等问题,查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_103)
Expand All @@ -65,11 +67,11 @@ Gitee:https://gitee.com/dromara/x-file-storage

### 📅更新计划

- 接入存储平台:HDFS、FastDFS、杉岩 OBS、Samba、NFS
- 大文件手动分片上传(1.0.0 已支持大文件自动分片上传)
- 复制或移动文件
- 接入存储平台:HDFS、火山云 TOS、Samba、NFS
- 用户端直传
- 追加缩略图
- 列出文件
- 文件内容预加载
- 上传无需强制获取 Size
- 新增 Access 模块,尝试通过 HTTP、FTP、WebDAV 等协议对外提供接口,方便其它程序使用

-------
Expand All @@ -87,7 +89,7 @@ Gitee:https://gitee.com/dromara/x-file-storage
<dependency>
<groupId>org.dromara.x-file-storage</groupId>
<artifactId>x-file-storage-spring</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
<!-- 引入 阿里云 OSS SDK,如果使用其它存储平台,就引入对应的 SDK -->
<dependency>
Expand All @@ -99,6 +101,8 @@ Gitee:https://gitee.com/dromara/x-file-storage

`application.yml` 配置文件中添加以下基础配置

关于配置文件及 FileInfo 中各种路径(path)的区别,可以参考 [常见问题](https://x-file-storage.xuyanwu.cn/#/常见问题?id=配置文件及-fileinfo-中各种路径(path)的区别?)

```yaml
dromara:
x-file-storage: #文件存储配置
Expand Down Expand Up @@ -263,6 +267,11 @@ X File Storage 的源码分为两个分支,功能如下:
5. 登录 Gitee 或 Github 在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可
6. 等待维护者合并

#### 🧬 开发约定 & 配置
1. JDK 11+、Maven 3.8.1+
2. 代码风格,目前代码风格通过 spotless-maven-plugin + palantir-java-format 统一控制,Maven 构建时统一格式化代码
3. 在开发阶段,IDE 要识别到 spotless-maven-plugin + palantir-java-format 需要安装插件:[palantir-java-format](https://plugins.jetbrains.com/plugin/13180-palantir-java-format)

#### 📐PR遵照的原则

欢迎任何人为 X File Storage 添砖加瓦,贡献代码,为了易用性和可维护性,需要提交的 pr(pull request)符合一些规范,规范如下:
Expand Down
19 changes: 17 additions & 2 deletions docs/Metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 使用

可以在上传时传入 Metadata 和 UserMetadata ,目前仅 华为云 OBS、阿里云 OSS、腾讯云 COS、百度云 BOS、七牛云 Kodo、又拍云 USS、MinIO、Amazon S3、GoogleCloud Storage 平台支持
可以在上传时传入 Metadata 和 UserMetadata ,目前仅 华为云 OBS、阿里云 OSS、腾讯云 COS、百度云 BOS、七牛云 Kodo、又拍云 USS、MinIO、Amazon S3、GoogleCloud Storage、FastDFS、Azure Blob Storage 平台支持

```java
//判断是否支持 Metadata
Expand Down Expand Up @@ -34,15 +34,30 @@ FileInfo fileInfo = fileStorageService.of(file)
```yaml
dromara:
x-file-storage:
upload-not-support-metadata-throw-exception: false
upload-not-support-metadata-throw-exception: false # 上传时
copy-not-support-metadata-throw-exception: false # 复制时
move-not-support-metadata-throw-exception: false # 移动时
```
**第二种(仅当前)**
```java
//上传时
FileInfo fileInfo = fileStorageService.of(file)
.setNotSupportMetadataThrowException(false) //在不支持 Metadata 的存储平台不抛出异常
.putUserMetadata("role","666")
.upload();

//复制时
FileInfo fileInfo = fileStorageService.copy(fileInfo)
.setNotSupportMetadataThrowException(false) //在不支持 Metadata 的存储平台不抛出异常
.setPlatform("local-plus-1")
.copy();

//移动时
FileInfo fileInfo = fileStorageService.move(fileInfo)
.setNotSupportMetadataThrowException(false) //在不支持 Metadata 的存储平台不抛出异常
.setPlatform("local-plus-1")
.move();
```


30 changes: 21 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@
<a target="_blank" href='https://github.com/dromara/x-file-storage'>
<img src="https://img.shields.io/github/stars/dromara/x-file-storage.svg?style=social" alt="github star"/>
</a>
<a href='https://gitee.com/dromara/x-file-storage'>
<a target="_blank" href='https://gitee.com/dromara/x-file-storage'>
<img src='https://gitee.com/dromara/x-file-storage/badge/star.svg?theme=dark' alt='star' />
</a>
<br />
<a href='https://jq.qq.com/?_wv=1027&k=eGfeNqka'>
<img src='https://img.shields.io/badge/QQ%E7%BE%A4-515706495-orange' alt='' />
<a target="_blank" href='https://jq.qq.com/?_wv=1027&k=eGfeNqka'>
<img src='https://img.shields.io/badge/QQ%E7%BE%A4-515706495-orange' alt='515706495' />
</a>
</p>

[tg.md](https://x-file-storage.xuyanwu.cn/assets/tg/tg.md ':include')

-------

# 📚简介

一行代码将文件存储到本地、FTP、SFTP、WebDAV、阿里云 OSS、华为云 OBS、七牛云 Kodo、腾讯云 COS、百度云 BOS、又拍云 USS、MinIO、
Amazon S3、GoogleCloud Storage、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动 云EOS、沃云 OSS、
Amazon S3、GoogleCloud Storage、FastDFS、 Azure Blob Storage、Cloudflare R2、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动 云EOS、沃云 OSS、
网易数帆 NOS、Ucloud US3、青云 QingStor、平安云 OBS、首云 OSS、IBM COS、其它兼容 S3 协议的存储平台。查看 [所有支持的存储平台](存储平台)

💡 通过 WebDAV 连接到 Alist 后,可以使用百度网盘、天翼云盘、阿里云盘、迅雷网盘等常见存储服务,查看 [Alist 支持的存储平台](https://alist-doc.nn.ci/docs/webdav)
Expand All @@ -51,6 +52,8 @@ Gitee:https://gitee.com/dromara/x-file-storage

这里是简要的更新记录,查看 [详细的更新记录](更新记录)

`2.1.0` 修复大量问题,新增存储平台 FastDFS 和 Azure Blob Storage,新增复制、移动(重命名)文件,手动分片上传(断点续传)和计算哈希等功能,详情查看 [更新记录](更新记录?id=_210)
<br />
`2.0.0` 捐赠至 [dromara](https://dromara.org/zh) 开源社区,更改项目名、包名,优化项目结构、支持 Metadata 元数据等,从旧版升级需要注意,详情查看 [更新记录](更新记录?id=_200)
<br />
`1.0.3` 修复了 FileStorageClientFactory 未自动加载等问题,查看 [更新记录](更新记录?id=_103)
Expand All @@ -65,11 +68,11 @@ Gitee:https://gitee.com/dromara/x-file-storage

# 📅更新计划

- 接入存储平台:HDFS、FastDFS、杉岩 OBS、Samba、NFS
- 大文件手动分片上传(1.0.0 已支持大文件自动分片上传)
- 复制或移动文件
- 接入存储平台:HDFS、火山云 TOS、Samba、NFS
- 用户端直传
- 追加缩略图
- 列出文件
- 文件内容预加载
- 上传无需强制获取 Size
- 新增 Access 模块,尝试通过 HTTP、FTP、WebDAV 等协议对外提供接口,方便其它程序使用

-------
Expand Down Expand Up @@ -288,6 +291,15 @@ X File Storage 感谢各位小伙伴的信任与支持,如果您已经在项
<a href="https://x-file-storage.xuyanwu.cn" target="_blank">
<img src="https://x-file-storage.xuyanwu.cn/assets/logo3.svg" alt="x-file-storage" title="">
</a>
<a href="https://wemq.nicholasld.cn" target="_blank">
<img src="https://x-file-storage.xuyanwu.cn/assets/link/WeMQ.png" alt="WeMQAQ" title="开源、高性能、安全、功能强大的物联网调试和管理解决方案。">
</a>
<a href="https://www.yuque.com/may-fly/mayfly-go" target="_blank">
<img src="https://x-file-storage.xuyanwu.cn/assets/link/mayfly-go.png" alt="Mayfly-Go" title="web版 linux、数据库、redis、mongo统一管理操作平台。">
</a>
<a href="https://akali.yomahub.com" target="_blank">
<img src="https://x-file-storage.xuyanwu.cn/assets/link/Akali.png" alt="Akali" title="Akali(阿卡丽),轻量级本地化热点检测/降级框架,10秒钟即可接入使用!大流量下的神器">
</a>
<a href="https://dromara.org/zh/projects/" target="_blank">
<img src="https://x-file-storage.xuyanwu.cn/assets/link/dromara.png" alt="dromara" title="让每一位开源爱好者,体会到开源的快乐。">
</a>
Expand Down
3 changes: 2 additions & 1 deletion docs/_navbar.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* 🌟文档版本 2.0.0
* 🌟文档版本 2.1.0

* [2.1.0](https://x-file-storage.xuyanwu.cn/2.1.0/)
* [2.0.0](https://x-file-storage.xuyanwu.cn/2.0.0/)
* [1.0.3](https://x-file-storage.xuyanwu.cn/1.0.3/)
* [1.0.2](https://x-file-storage.xuyanwu.cn/1.0.2/)
Expand Down
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [🥦存储平台](存储平台 "存储平台")
* [🌽文件适配器](文件适配器 "文件适配器")
* [🔍️识别文件的 MIME 类型](识别文件的MIME类型 "识别文件的 MIME 类型")
* [🍵️计算哈希](hash "hash")
* [🧪切面](切面 "切面")
* [🌱脱离 SpringBoot 单独使用](脱离SpringBoot单独使用 "脱离 SpringBoot 单独使用")
* [🙋‍♂️常见问题](常见问题 "常见问题")
Expand Down
Loading

0 comments on commit b568c05

Please sign in to comment.