💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ package com.nobb.controller.admin; import com.nobb.util.Response; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.IOException; import java.util.Map; @Controller public class UploadController { @RequestMapping("/upload") @ResponseBody public Map upload(@RequestParam("file") MultipartFile file){ System.out.println(file); if (file.isEmpty()) { return Response.error(400, "error"); } String fileName = file.getOriginalFilename(); String filePath = "D:/temp/"; File dest = new File(filePath + fileName); try { file.transferTo(dest); return Response.msg(0,null,"success"); } catch (IOException e) { } return Response.error(400, "error"); } } ~~~