首先答案是肯定的,fastdfs不支援windows。
其次建議你使用Minio
一、引言
一般來說檔案存儲花錢就選擇阿裡雲oss、七牛雲等産品,開源的話,目前開源的分布式檔案存儲系統非常多,上網一搜 "Ceph,GlusterFS,Sheepdog,
Lustre,Swift,Cinder,TFS,HDFS,MooseFS,FastDFS,MogileFS等" 這麼多,有沒有感覺看完對這些産品的分析後,還是不知道選擇哪個????
這是一篇針對主流的開源的分布式檔案存儲系統的對比文章:
開源分布式存儲系統的對比_直到世界的盡頭-CSDN部落格_四大開源分布式存儲blog.csdn.net/zzq900503/article/details/80020725
二、那到底選擇哪個呢?
2.1、實在沒法選擇時,我們先看看幾開源産品github 的 star
分布式檔案系統 | github star | os支援 |
minio | 25.1k | win/linux |
fastdfs | 7k | linux |
ceph | 8.6k | win/linux |
GlusterFS | 2.9k | win/linux |
2.2、推薦使用minio
看看這篇文章:《MinIO很強-讓我放棄FastDFS擁抱MinIO的8個理由》
MinIO很強-讓我放棄FastDFS擁抱MinIO的8個理由www.cnblogs.com/zimug/p/13444086.html
三、minio安裝與使用
3.1、 windows安裝非常簡單
官網直接下載下傳:
https://min.io/min.io/
啟動就這麼簡單, F:\Data 就是檔案存儲的目錄
3.3、java調用minio
在官方上有相應的demo,不過官網引用的版本比較舊,相應的demo也比較舊,最新的demo我們可以去github上看。
githug examples:
https://github.com/minio/minio-javagithub.com/minio/minio-java
minio/minio-java
https://github.com/minio/minio-javagithub.com/minio/minio-java
以下代碼基于官方github微調後的示例
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.0.3</version>
</dependency>
class MinioTest {
MinioClient minioClient;
@BeforeEach
void setUp() {
minioClient =
MinioClient.builder()
.endpoint("https://play.min.io")
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")
.build();
}
/**
* 上傳檔案
*
* @throws Exception
*/
@Test
void test_upload() throws Exception {
minioClient.uploadObject(
UploadObjectArgs.builder()
.bucket("bucket01")
.object("test.txt")
.filename("D:\\data\\Desktop\\test.txt")
.build());
System.out.println("my-filename is uploaded to my-objectname successfully");
}
/**
* 下載下傳檔案
*
* @throws Exception
*/
@Test
void test_download() throws Exception {
minioClient.downloadObject(
DownloadObjectArgs.builder()
.bucket("bucket01")
.object("test.txt")
.filename("D:\\data\\Desktop\\test.txt")
.build());
System.out.println("my-filename is uploaded to my-objectname successfully");
}
/**
* 擷取檔案URL
*
* @throws Exception
*/
@Test
void test_geturl() throws Exception {
String url =
minioClient.getPresignedObjectUrl(
GetPresignedObjectUrlArgs.builder()
.method(Method.GET)
.bucket("bucket01")
.object("test.txt")
.expiry(60 * 60 * 24)
.build());
System.out.println(url);
}
/**
* 上傳+加密
*
* @throws Exception
*/
@Test
void test_upload_sse() throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
ServerSideEncryptionCustomerKey ssec =
new ServerSideEncryptionCustomerKey(keyGen.generateKey());
minioClient.uploadObject(
UploadObjectArgs.builder()
.bucket("bucket01")
.object("test-sse-01.txt")
.filename("D:\\data\\Desktop\\test.txt")
.sse(ssec)
.build());
System.out.println("my-filename is uploaded to my-objectname successfully");
}
/**
* 下載下傳+解密
*
* @throws Exception
*/
@Test
void test_download_sse() throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
ServerSideEncryptionCustomerKey ssec =
new ServerSideEncryptionCustomerKey(keyGen.generateKey());
minioClient.downloadObject(
DownloadObjectArgs.builder()
.bucket("bucket01")
.object("test-sse-01.txt")
.filename("D:\\data\\Desktop\\_test-sse-01.txt")
.ssec(ssec) // Replace with same SSE-C used at the time of upload.
.build());
System.out.println("my-objectname is successfully downloaded to my-filename");
}
/**
* 如何儲存上傳時的密鑰對象
*
* @throws Exception
*/
@Test
void test_key() throws Exception {
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
SecretKey key1 = keyGen.generateKey();
byte[] keySave = key1.getEncoded();
System.out.println("key1 = " + Base64.getEncoder().encodeToString(keyBytes));
//這裡把keySave 儲存下來就可以了,當然我們可以轉成base64儲存
//以下就是把存儲下來的keySave還原成SecretKey對象
SecretKey key2 = new SecretKeySpec(keySave , "AES");
System.out.println("key2 = " + Base64.getEncoder().encodeToString(key2 .getEncoded()));
//key1 == key2
assertEquals(key1,key2);
}
}