我正在尝试编写一个方法,该方法接受存储在mongoDB中的JSON对象并向用户提供ics / ics文件。 到目前为止,这是我的代码:
@RequestMapping(value = "/ical", method = RequestMethod.GET)
public void getIcalFile(
String json,
HttpServletResponse response) {
try {
// get your file as InputStream
InputStream is = //Input stream from JSON. HOW?
// copy it to response's OutputStream
IOUtils.copy(is, response.getOutputStream());
response.flushBuffer();
} catch (IOException ex) {
//log.info("Error writing file to output stream. Filename was '" + fileName + "'");
throw new RuntimeException("IOError writinethod that takes a JSON object and serves a ical/ics file to the user. This is my code so far:g file to output stream");
}
}
我不知道如何获取JSON对象并将其用作输入流。如果有更好的方法来实现我想要实现的目标,我会喜欢一个建议。