當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。