当前位置: 首页>>代码示例>>Java>>正文


Java Http.MultipartFormData方法代码示例

本文整理汇总了Java中play.mvc.Http.MultipartFormData方法的典型用法代码示例。如果您正苦于以下问题:Java Http.MultipartFormData方法的具体用法?Java Http.MultipartFormData怎么用?Java Http.MultipartFormData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在play.mvc.Http的用法示例。


在下文中一共展示了Http.MultipartFormData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importGrades

import play.mvc.Http; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result importGrades() {
    Http.MultipartFormData<File> body = request().body().asMultipartFormData();
    Http.MultipartFormData.FilePart<File> filePart = body.getFile("file");
    if (filePart == null) {
        return notFound();
    }
    File file = filePart.getFile();
    User user = getLoggedUser();
    boolean isAdmin = user.hasRole(Role.Name.ADMIN.toString(), getSession());
    try {
        CsvBuilder.parseGrades(file, user, isAdmin ? Role.Name.ADMIN : Role.Name.TEACHER);
    } catch (IOException e) {
        Logger.error("Failed to parse CSV file. Stack trace follows");
        e.printStackTrace();
        return internalServerError("sitnet_internal_error");
    }
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:20,代码来源:ReviewController.java

示例2: upload

import play.mvc.Http; //导入方法依赖的package包/类
public Result upload() {
    // Get the current logged in user
    User user = User.find.byId(Long.parseLong(session().get("uid")));

    // Process form submission as multipart form data
    Http.MultipartFormData body = request().body().asMultipartFormData();

    UserUpload userUpload = null;

    for (Object obj : body.getFiles()) {
        Http.MultipartFormData.FilePart filePart = (Http.MultipartFormData.FilePart) obj;
        userUpload = uploadFile(filePart, user);
    }

    if (userUpload != null) {
        return ok("{ 'filename' : " + userUpload.getFileName() + "}");
    } else {
        return internalServerError("{ }");
    }

}
 
开发者ID:kurator-org,项目名称:kurator-web,代码行数:22,代码来源:Workflows.java

示例3: deployWorkflows

import play.mvc.Http; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result deployWorkflows() {
    Http.MultipartFormData body = request().body().asMultipartFormData();
    Http.MultipartFormData.FilePart filePart = body.getFile("filename");

    if (filePart != null) {
        ConfigManager configManager = ConfigManager.getInstance();

        char[] keystorePassword = ConfigFactory.defaultApplication().getString("keystore.password").toCharArray();
        String keystoreLocation = ConfigFactory.defaultApplication().getString("keystore.location");

        try {
            File zipFile = (File) filePart.getFile();
            WorkflowPackageVerifier verifier = new WorkflowPackageVerifier();
            verifier.checkIntegrity(zipFile, keystoreLocation, keystorePassword);

            configManager.unpack((File) filePart.getFile());
        } catch (Exception e) {
            flash("error", "Could not verify package.");
            return redirect(routes.Workflows.deploy());
        }

        flash("message", "Packages zip file was successfully deployed");
        return redirect(routes.Workflows.deploy());
    } else {
        flash("error", "Missing file");
        return badRequest();
    }
}
 
开发者ID:kurator-org,项目名称:kurator-web,代码行数:30,代码来源:Workflows.java


注:本文中的play.mvc.Http.MultipartFormData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。