本文整理了Java中org.springframework.web.multipart.MultipartFile.transferTo()
方法的一些代码示例,展示了MultipartFile.transferTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultipartFile.transferTo()
方法的具体详情如下:
包路径:org.springframework.web.multipart.MultipartFile
类名称:MultipartFile
方法名:transferTo
[英]Transfer the received file to the given destination file.
This may either move the file in the filesystem, copy the file in the filesystem, or save memory-held contents to the destination file. If the destination file already exists, it will be deleted first.
If the file has been moved in the filesystem, this operation cannot be invoked again. Therefore, call this method just once to be able to work with any storage mechanism.
[中]将接收到的文件传输到给定的目标文件。
这可能会将文件移动到文件系统中,将文件复制到文件系统中,或者将内存中的内容保存到目标文件中。如果目标文件已存在,将首先删除它。
如果文件已在文件系统中移动,则无法再次调用此操作。因此,只需调用此方法一次,就可以使用任何存储机制。
代码示例来源:origin: stackoverflow.com
public File multipartToFile(MultipartFile multipart) throws IllegalStateException, IOException
{
File convFile = new File( multipart.getOriginalFilename());
multipart.transferTo(convFile);
return convFile;
}
代码示例来源:origin: stackoverflow.com
File dest = new File(filePath);
try {
multipartFile.transferTo(dest);
} catch (IllegalStateException e) {
e.printStackTrace();
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: roncoo/spring-boot-demo
file.transferTo(dest);
return "上传成功";
} catch (IllegalStateException e) {
代码示例来源:origin: stylefeng/Guns
/**
* 上传图片
*
* @author fengshuonan
* @Date 2018/12/24 22:44
*/
@RequestMapping(method = RequestMethod.POST, path = "/upload")
@ResponseBody
public String upload(@RequestPart("file") MultipartFile picture) {
String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(picture.getOriginalFilename());
try {
String fileSavePath = gunsProperties.getFileUploadPath();
picture.transferTo(new File(fileSavePath + pictureName));
} catch (Exception e) {
throw new ServiceException(BizExceptionEnum.UPLOAD_ERROR);
}
return pictureName;
}
}
代码示例来源:origin: sanluan/PublicCMS
/**
* 上传文件
*
* @param file
* @param fileName
* @return file name
* @throws IllegalStateException
* @throws IOException
*/
public String upload(MultipartFile file, String fileName) throws IllegalStateException, IOException {
File dest = new File(fileName);
dest.getParentFile().mkdirs();
file.transferTo(dest);
return dest.getName();
}
代码示例来源:origin: sanluan/PublicCMS
/**
* 上传文件
*
* @param file
* @param fileName
* @return file name
* @throws IllegalStateException
* @throws IOException
*/
public String upload(MultipartFile file, String fileName) throws IllegalStateException, IOException {
File dest = new File(fileName);
dest.getParentFile().mkdirs();
file.transferTo(dest);
return dest.getName();
}
代码示例来源:origin: zhangxd1989/springboot-dubbox
/**
* 文件类型转换
*
* @param file MultipartFile
* @return File file
*/
public static File transfer(MultipartFile file) {
File upFile = new File(new File(TEMP_FILE_PATH), file.getOriginalFilename());
try {
file.transferTo(upFile);
} catch (IllegalStateException | IOException ex) {
throw new SystemException(ex);
}
return upFile;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public MultipartFile readMultipartFile(MultipartFile multipartFile) throws IOException {
File upload = File.createTempFile(this.prefix, this.suffix, this.directory);
multipartFile.transferTo(upload);
UploadedMultipartFile uploadedMultipartFile = new UploadedMultipartFile(upload, multipartFile.getSize(),
multipartFile.getContentType(), multipartFile.getName(), multipartFile.getOriginalFilename());
if (logger.isDebugEnabled()) {
logger.debug("copied uploaded file [" + multipartFile.getOriginalFilename() +
"] to [" + upload.getAbsolutePath() + "]");
}
return uploadedMultipartFile;
}
代码示例来源:origin: bill1012/AdminEAP
file.transferTo(serverFile);
SysFile sysFile=new SysFile();
sysFile.setFileName(file.getOriginalFilename());
内容来源于网络,如有侵权,请联系作者删除!