springboot 1.X 实现 jersey

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import org.springframework.web.multipart.MultipartFile;
	public String doPutToFileServer(MultipartFile file, String url) {

		String fileName = file.getOriginalFilename();
		String uploadUrl = FileNameCreator.creatRandomName(url, fileName);
		Client client = new Client();
		WebResource webResource = client.resource(uploadUrl);
		try {
			byte[] buf = file.getBytes();
			webResource.put(String.class,buf);
			return uploadUrl;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

pom.xml

<!-- 实现文件与业务服务器分离 -->
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-client</artifactId>
			<version>1.18.1</version>
		</dependency>

详细内容:看利用jersey 实现图片的上传

猜你喜欢

转载自blog.csdn.net/m0_38044453/article/details/80899912
今日推荐