在playframework中上传多个文件

在playframework中上传多个文件,第1张

在playframework中上传多个文件

如果有人感兴趣的话,可以像这样工作:

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”)。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5502064.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-12
下一篇2022-12-12

发表评论

登录后才能评论

评论列表(0条)

    保存