国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Springboot整合fastdfs-分布式文件存儲(chǔ)

這篇具有很好參考價(jià)值的文章主要介紹了Springboot整合fastdfs-分布式文件存儲(chǔ)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、快速開始
1、添加依賴
 <dependency>
    <groupId>com.luhuiguo</groupId>
    <artifactId>fastdfs-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>
<dependency>
    <groupId>org.csource</groupId>
    <artifactId>fastdfs-client-java</artifactId>
    <version>1.27-SNAPSHOT</version>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-configuration-processor</artifactId>
	<optional>true</optional>
</dependency>
2、添加配置項(xiàng)
# fdfs配置
fdfs:
  connect-timeout: 2000 # 連接服務(wù)器超時(shí)時(shí)間
  so-timeout: 3000    
  tracker-list: ${ip}:${port}
  http:
    path: http://${ip}:${port}/ #http鏈接前綴   
3、新建 fdfs_client.conf(可忽略)
connect_timeout = 60
network_timeout = 60
charset = UTF-8
http.tracker_http_port = 8080
http.anti_steal_token = no
http.secret_key = 123456
tracker_server = 192.168.53.85:22122
2、FastDFS客戶端工具
@Slf4j
public class FastDFSClient {
	//分片客戶端
    private static TrackerClient trackerClient;
    //分片服務(wù)端
	private static TrackerServer trackerServer;
    //存儲(chǔ)桶客戶端
	private static StorageClient storageClient;
    //存儲(chǔ)桶服務(wù)端
	private static StorageServer storageServer;
	
	static {
		try {
            //引入配置
			String filePath = new ClassPathResource("fdfs_client.conf").getFile().getAbsolutePath();;
			ClientGlobal.init(filePath);
			trackerClient = new TrackerClient();
			trackerServer = trackerClient.getConnection();
			storageServer = trackerClient.getStoreStorage(trackerServer);
		} catch (Exception e) {
			logger.error("FastDFS Client Init Fail!",e);
		}
	}
    
    //文件上傳
    @SneakyThrows
	public static String[] upload(FastDFSFile file) {
		NameValuePair[] meta_list = new NameValuePair[1];
		meta_list[0] = new NameValuePair("author", file.getAuthor());
		long startTime = System.currentTimeMillis();
		String[] uploadResults = null;
		storageClient = new StorageClient(trackerServer, storageServer);
        uploadResults = storageClient.upload_file(file.getContent(), file.getExt(), meta_list);
        if(null == uploadResults) return null;
		String groupName = uploadResults[0];
		String remoteFileName = uploadResults[1];
		return uploadResults;
	}
    
    //獲取File
    @SneakyThrows
	public static FileInfo getFile(String groupName, String remoteFileName) {
		storageClient = new StorageClient(trackerServer, storageServer);
        return storageClient.get_file_info(groupName, remoteFileName);
	}
    
    //下載文件
    @SneakyThrows
	public static InputStream downFile(String groupName, String remoteFileName) {
		storageClient = new StorageClient(trackerServer, storageServer);
        byte[] fileByte = storageClient.download_file(groupName, remoteFileName);
        InputStream ins = new ByteArrayInputStream(fileByte);
        return ins;
	}
    
    //刪除文件
    @SneakyThrows
	public static void deleteFile(String groupName, String remoteFileName) {
		storageClient = new StorageClient(trackerServer, storageServer);
		int i = storageClient.delete_file(groupName, remoteFileName);
		logger.info("delete file successfully!!!" + i);
	}
    
    //獲取存儲(chǔ)器
    @SneakyThrows
	public static StorageServer[] getStoreStorages(String groupName){
		return trackerClient.getStoreStorages(trackerServer, groupName);
	}
    
    //獲取FetchStorages
    @SneakyThrows
	public static ServerInfo[] getFetchStorages(String groupName,String remoteFileName) {
		return trackerClient.getFetchStorages(trackerServer, groupName, remoteFileName);
	}
    
    // 獲取存儲(chǔ)器的URL
    @SneakyThrows
	public static String getTrackerUrl() {
		return "http://"+trackerServer.getInetSocketAddress().getHostString()+":"
            +ClientGlobal.getG_tracker_http_port()+"/";
	}
    @Data
    public static class FastDFSFile {
        //文件名
        private String name;
        //文件內(nèi)容
        private byte[] content;
        //文件拓展名
        private String ext;
        //文件的md5
        private String md5;
        //文件做著
        private String author;
    }
}

文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-668015.html

到了這里,關(guān)于Springboot整合fastdfs-分布式文件存儲(chǔ)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 搭建單機(jī)版FastDFS分布式文件存儲(chǔ)系統(tǒng)

    搭建單機(jī)版FastDFS分布式文件存儲(chǔ)系統(tǒng)

    1、下載FastDFS安裝包和依賴包 https://codeload.github.com/happyfish100/libfastcommon/tar.gz/V1.0.43 https://codeload.github.com/happyfish100/fastdfs/tar.gz/V6.06 https://codeload.github.com/happyfish100/fastdfs-nginx-module/tar.gz/V1.22 注:可以使用window瀏覽器(下載后需要上傳到服務(wù)器上),也可以使用linux的curl命令 2、

    2024年02月09日
    瀏覽(29)
  • 分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【三】

    分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【三】

    7.2.1.Admin 7.2.2.Menu 7.2.3.MenuBean 7.2.4.Role 7.2.5.RoleMenu 7.4.1.AuthContextHolder 7.4.2.HttpUtils 7.4.3.StringUtils 7.4.4.JwtHelper 7.4.5.MD5 7.4.6.ShiroMD5 7.5.1.AdminMapper.xml 7.5.2.MenuMapper.xml 7.5.3.RoleMenuMapper.xml 7.5.4.AdminMapper 7.5.5.MenuMapper 7.5.6.RoleMenuMapper 7.6.1.AdminService 7.6.2.MenuBeanService 7.6.3.MenuService 7.6.4.RoleMenu

    2024年02月22日
    瀏覽(26)
  • 分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【一】

    分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【一】

    操作系統(tǒng)中負(fù)責(zé)管理和存儲(chǔ)文件信息的軟件機(jī)構(gòu)稱為文件管理系統(tǒng),簡(jiǎn)稱文件系統(tǒng)。 常見的文件系統(tǒng):FAT16/FAT32、NTFS、HFS、UFS、APFS、XFS、Ext4等 。 分布式文件系統(tǒng)(Distributed File System,DFS) 是指文件系統(tǒng)管理的物理存儲(chǔ)資源不一定直接連接在本地節(jié)點(diǎn)上,而是通過計(jì)算機(jī)網(wǎng)

    2024年02月20日
    瀏覽(18)
  • 分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【四】

    分布式文件系統(tǒng) SpringBoot+FastDFS+Vue.js【四】

    案例有些不足 功能太簡(jiǎn)單 功能復(fù)雜可以做一個(gè)類似網(wǎng)盤的文件管理系統(tǒng) 僅僅學(xué)習(xí)使用某些功能 暫不深入開發(fā) 有興趣的伙伴可以嘗試一番 類似于阿里云oss

    2024年02月20日
    瀏覽(19)
  • 在Docker里安裝FastDFS分布式文件系統(tǒng)詳細(xì)步驟

    在Docker里安裝FastDFS分布式文件系統(tǒng)詳細(xì)步驟

    使用docker鏡像構(gòu)建tracker容器,用于啟動(dòng)跟蹤服務(wù)器,起到調(diào)度的作用。 其中-v參數(shù)將本地的目錄與容器中的/var/fdfs目錄進(jìn)行掛載 使用的網(wǎng)絡(luò)模式是–net=host –name容器名 -d后臺(tái)啟動(dòng) 使用docker鏡像構(gòu)建storage容器,用于啟動(dòng)存儲(chǔ)服務(wù)器,提供容量和備份服務(wù)。 在執(zhí)行下面命令時(shí)

    2024年02月03日
    瀏覽(15)
  • 【分布式技術(shù)專題】「OSS中間件系列」Minio的文件服務(wù)的存儲(chǔ)模型及整合Java客戶端訪問的實(shí)戰(zhàn)指南

    【分布式技術(shù)專題】「OSS中間件系列」Minio的文件服務(wù)的存儲(chǔ)模型及整合Java客戶端訪問的實(shí)戰(zhàn)指南

    Minio的元數(shù)據(jù) 數(shù)據(jù)存儲(chǔ) MinIO對(duì)象存儲(chǔ)系統(tǒng)沒有元數(shù)據(jù)數(shù)據(jù)庫(kù),所有的操作都是對(duì)象級(jí)別的粒度的,這種做法的優(yōu)勢(shì)是: 個(gè)別對(duì)象的失效,不會(huì)溢出為更大級(jí)別的系統(tǒng)失效。 便于實(shí)現(xiàn)\\\"強(qiáng)一致性\\\"這個(gè)特性。此特性對(duì)于機(jī)器學(xué)習(xí)與大數(shù)據(jù)處理非常重要。 數(shù)據(jù)管理 元數(shù)據(jù)與數(shù)據(jù)一起

    2024年02月11日
    瀏覽(21)
  • 開源輕量級(jí)分布式文件系統(tǒng)FastDFS本地部署并實(shí)現(xiàn)遠(yuǎn)程訪問服務(wù)器

    開源輕量級(jí)分布式文件系統(tǒng)FastDFS本地部署并實(shí)現(xiàn)遠(yuǎn)程訪問服務(wù)器

    FastDFS是一個(gè)開源的輕量級(jí)分布式文件系統(tǒng),它對(duì)文件進(jìn)行管理,功能包括:文件存儲(chǔ)、文件同步、文件訪問(文件上傳、文件下載)等,解決了大容量存儲(chǔ)和負(fù)載均衡的問題。特別適合以文件為載體的在線服務(wù),如相冊(cè)網(wǎng)站、視頻網(wǎng)站等等。 FastDFS為互聯(lián)網(wǎng)量身定制,充分考

    2024年02月04日
    瀏覽(116)
  • C++ 網(wǎng)絡(luò)編程項(xiàng)目fastDFS分布式文件系統(tǒng)(四)-fastCGI項(xiàng)目相關(guān)技術(shù)以及l(fā)inux搜狗輸入法相關(guān)問題。

    C++ 網(wǎng)絡(luò)編程項(xiàng)目fastDFS分布式文件系統(tǒng)(四)-fastCGI項(xiàng)目相關(guān)技術(shù)以及l(fā)inux搜狗輸入法相關(guān)問題。

    目錄 1. Nginx作為web服務(wù)器處理請(qǐng)求 2. http協(xié)議復(fù)習(xí) ? ? ??Get方式提交數(shù)據(jù) Post方式提交數(shù)據(jù) 3. fastCGI ? 3.1 CGI ?3.2 fastCGI 3.3 fastCGI和spawn-fcgi安裝 ????????1. 安裝fastCGI ? ??2. 安裝spawn-fcgi 3.4 nginx fastcgi? ?? 4其他知識(shí)點(diǎn) 1. fastCGI環(huán)境變量 - fastcgi.conf ?2. 客戶端使用Post提交數(shù)據(jù)

    2024年02月12日
    瀏覽(20)
  • 【分布式緩存】springboot整合jetcache使用詳解

    目錄 一、前言 二、多級(jí)緩存問題 2.1 緩存分類 2.1.1 本地緩存 2.1.2 分布式緩存

    2024年02月17日
    瀏覽(20)
  • 分布式數(shù)據(jù)(文件)存儲(chǔ)

    分布式數(shù)據(jù)(文件)存儲(chǔ)

    在分布式存儲(chǔ)里面,比較常見的有kafka,Hbase,HDFS,fastDFS等,這里面涉及到文件的分布式存儲(chǔ)以及數(shù)據(jù)的分布式存儲(chǔ)。分布式存儲(chǔ)的背景:就是將數(shù)據(jù)文件分散的存儲(chǔ)到分布式集群的每一個(gè)節(jié)點(diǎn),提升了存儲(chǔ)的容量(大數(shù)據(jù)化);同時(shí)盡量凸顯分布式的檢索能力。分布式存儲(chǔ)的原

    2024年02月07日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包