@RequestMapping(value="/files/{name}/contents", method= RequestMethod.POST)
public void postFile(@PathVariable(name = "name") String name, @RequestBody byte[] content) {
11 回复
试了@Ok("raw") 还是取不到content
/**
* 保存更新文件
* @param name
* @param content
*/
@RequestMapping(value="/files/{name}/contents", method= RequestMethod.POST)
public void postFile(@PathVariable(name = "name") String name, @RequestBody byte[] content) {
// 文件的路径
String path = filePath + name;
File file = new File(path);
FileOutputStream fop = null;
try {
if (!file.exists()) {
file.createNewFile();//构建文件
}
fop = new FileOutputStream(file);
fop.write(content);
fop.flush();
System.out.println("------------ save file ------------ ");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fop.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
改的
/**
* 保存更新文件
* @param name
* @param content
*/
@At("/files/?/contents")
@POST
@Ok("raw")
public void postFile(@Param("name") String name, byte[] content) {
// 文件的路径
String path = filePath + name;
File file = new File(path);
FileOutputStream fop = null;
try {
if (!file.exists()) {
file.createNewFile();//构建文件
}
fop = new FileOutputStream(file);
fop.write(content);
fop.flush();
System.out.println("------------ save file ------------ ");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fop.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@wendal office online server 在线编辑 office 文件
@wendal 不懂呢 怎么 写?
@wendal 懂了 谢谢 大牛
添加回复
请先登陆