
如果有人感兴趣的话,可以像这样工作:
public static void uploadPictures(long id, String title, File fake) { List<Upload> files = (List<Upload>) request.args.get("__UPLOADS"); if(files != null) { Project project = Project.findById(id); Picture picture; Blob image; InputStream inStream; for(Upload file: files) { if(file != null) { try { inStream = new java.io.FileInputStream(file.asFile()); image = new Blob(); image.set(inStream, new MimetypesFileTypeMap().getContentType(file.asFile())); picture = new Picture(project, file.getFileName(), image); project.addPicture(picture); // stores the picture } catch (FileNotFoundException e) { System.out.println(e.toString()); } } } } addPicture(id); //renders the image upload view}如果可能的话,很高兴获得带有Blob对象数组的可行解决方案,而不必要求request.args.get(“ __ UPLOADS”)。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)