All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.leopard.data.dfs.service.DfsServiceImpl Maven / Gradle / Ivy

Go to download

分布式文件系统实现,目前只是做了基于GridFS的实现,可以在本机文件系统进行缓存。

There is a newer version: 0.9.12
Show newest version
package io.leopard.data.dfs.service;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DfsServiceImpl implements DfsService {

	@Autowired
	private DfsDao dfsDao;

	@Autowired
	private FileDao fileDao;

	@Override
	public void write(String filename, byte[] data, long uid) throws IOException {
		if (data.length <= 0) {
			throw new IllegalArgumentException("文件不能为空.");
		}

		dfsDao.write(filename, data, uid);

		fileDao.add(uid, filename);
	}

	@Override
	public byte[] read(String filename) throws IOException {
		return dfsDao.read(filename);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy