朋友我的代码有问题
我想将MultipartFile转换为pdf并在特定位置下载,任何人都可以帮助我
@RequestMapping(value = "/uploadFile", method = RequestMethod.PUT, consumes = { "multipart/form-data" })
public Map<String, String> uploadFile(@RequestParam("uploadfile") MultipartFile pdfFile) throws Exception {
String url = pdfFile + "FileName";
File fileToSave = new File(url);
fileToSave.createNewFile();
FileOutputStream fos = new FileOutputStream(fileToSave);
fos.write(pdfFile.getBytes());
fos.close();
return null;
}
答案 0 :(得分:0)
请尝试使用此功能:
public static File convert(MultipartFile file) throws IOException {
File convFile = new File(file.getOriginalFilename());
convFile.createNewFile();
FileOutputStream fos = new FileOutputStream(convFile);
fos.write(file.getBytes());
fos.close();
return convFile;
}
答案 1 :(得分:0)
>>> import pandas as pd
>>>
>>> df = pd.read_csv("foo.txt", sep="\t")
>>> df
A B C
0 1 4 3
1 1 5 4
2 1 2 10
3 2 7 2
4 2 4 4
5 2 6 6
>>>
>>> def calc(data):
... length = len(data['B'])
... mx = data['B'][0]
... nx = data['C'][0]
... for i in range(1,length):
... my = data['B'][i]
... ny = data['C'][i]
... nx = nx + ny
... mx=(mx*nx+my*ny)/(nx+ny)
... return(mx)
...
>>> result = []
>>> for name, group in df.groupby('A'):
... group = pd.DataFrame(group).reset_index()
... out = calc(group)
... result.append(out)
...
>>> result
[3.488215488215488, 5.866666666666666]
.......................
Thanks, guys , I got Soluation ....Following code is going to work