In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the method of integrating fastdfs with springboot". In the daily operation, I believe that many people have doubts about the method of integrating fastdfs with springboot. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the method of integrating fastdfs with springboot". Next, please follow the editor to study!
1 introduction of jar
Com.github.tobato fastdfs-client 1.26.1-RELEASE
Description:
When the version of springboot is 2.0 or later, use the 1.26.1-RELEASE version
2 introduction configuration:
@ Configuration@Import (FdfsClientConfig.class) / / solve the problem of jmx repeatedly registering bean @ EnableMBeanExport (registration = RegistrationPolicy.IGNORE_EXISTING) public class FastClientImporter {}
3 yml configuration:
Fdfs: so-timeout: 1501 connect-timeout: 601thumb-image: # Thumbnail width: 60 height: 60 tracker-list: # tracker address 10.96.165.173 connect-timeout 22122
4 use:
@ Servicepublic class PictureServiceImpl implements PictureService {@ Autowired private FastFileStorageClient fastFileStorageClient; @ Value ("${IMAGE_SERVER_URL}") private String IMAGE_SERVER_URL; @ Override public String uploadPicture (MultipartFile file) {/ / intercept the suffix try {String originalFilename = file.getOriginalFilename (); System.out.println (originalFilename); String extName = originalFilename.substring (originalFilename.lastIndexOf (".") + 1) System.out.println (extName); StorePath storePath = fastFileStorageClient.uploadFile (file.getInputStream (), file.getSize (), FilenameUtils.getExtension (file.getOriginalFilename ()), null); System.out.println (storePath); String fileUrl = IMAGE_SERVER_URL + storePath.getFullPath (); return fileUrl;} catch (IOException e) {e.printStackTrace (); return null }}}
Build fastdfs server by docker
Prerequisite: install docker
Yum install-y docker-io
1 pull the image:
Docker pull qbanxiaoli/fastdfs
2 docker start
Docker run-d-restart=always-privileged=true-net=host-name=fastdfs-e IP=192.168.127.131-e WEB_PORT=80-v ${HOME} / fastdfs:/var/local/fdfs qbanxiaoli/fastdfs
3 Inspection:
Docker exec-it fastdfs / bin/bashecho "Hello FastDFS!" > index.htmlfdfs_test / etc/fdfs/client.conf upload index.html
Common errors:
Error code 28 is returned, indicating that there is insufficient disk space. Note that there is the concept of reserved space in FastDFS, which is set in tracker.conf. The configuration item is: reserved_storage_space, and the default value is 4GB, that is, reserved space for 4GB.
Resolve:
Please set the parameter reserved_storage_space as appropriate, for example, it can be set to about 20% of the total disk space.
At this point, the study on "the method of springboot integrating fastdfs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.