Package play.mvc.Http

Examples of play.mvc.Http.MultipartFormData


    }

    @BodyParser.Of(BodyParser.MultipartFormData.class)
    public Result create() {
        String path = getRefererPath();
        MultipartFormData body = request().body().asMultipartFormData();
        FilePart bundle = body.getFile("bundle");
        if (bundle != null) {
            CreateBundleRequest cbr;
            try {
                File file = bundle.getFile();
                String bundleContents = Files.toString(file, StandardCharsets.UTF_8);
View Full Code Here


          }
      });
  }

  public static Result upload() {
    MultipartFormData body = request().body().asMultipartFormData();
    MultipartFormData.FilePart uploadedFile = body.getFile("uploadedFile");
    if (uploadedFile == null) {
      return ok("Error when uploading");
    } else {
      String fileName = uploadedFile.getFilename();
      String contentType = uploadedFile.getContentType();
View Full Code Here

     * @return a 200 Status code when the import is successfull,a 500 status code otherwise
     */
    @With({RootCredentialWrapFilter.class,ConnectToDBFilter.class})
    public static Result importDb(){
      String appcode = (String)ctx().args.get("appcode");
      MultipartFormData  body = request().body().asMultipartFormData();
      if (body==null) return badRequest("missing data: is the body multipart/form-data?");
      FilePart fp = body.getFile("file");

      if (fp!=null){
        ZipInputStream zis = null;
        try{
          java.io.File multipartFile=fp.getFile();
View Full Code Here

     
      }else{
       
        IProperties i = (IProperties)PropertiesConfigurationHelper.findByKey(conf, key);
        if(i.getType().equals(ConfigurationFileContainer.class)){
          MultipartFormData  body = request().body().asMultipartFormData();
          if (body==null) return badRequest("missing data: is the body multipart/form-data?");
          FilePart file = body.getFile("file");
          if(file==null) return badRequest("missing file");
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          try{
            FileUtils.copyFile(file.getFile(),baos);
            Object fileValue = new ConfigurationFileContainer(file.getFilename(), baos.toByteArray());
View Full Code Here

  public static Result importDb(){
    String appcode = (String)ctx().args.get("appcode");
    if(appcode == null || StringUtils.isEmpty(appcode.trim())){
      unauthorized("appcode can not be null");
    }
    MultipartFormData  body = request().body().asMultipartFormData();
    if (body==null) return badRequest("missing data: is the body multipart/form-data?");
    FilePart fp = body.getFile("file");

    if (fp!=null){
      ZipInputStream zis = null;
      try{
        java.io.File multipartFile=fp.getFile();
View Full Code Here

 
 
    /*------------------FILE--------------------*/
  @With ({UserCredentialWrapFilter.class,ConnectToDBFilter.class})
    public static Result storeFile() throws  Throwable {
      MultipartFormData  body = request().body().asMultipartFormData();
      if (body==null) return badRequest("missing data: is the body multipart/form-data? Check if it contains boundaries too! " );
      //FilePart file = body.getFile(FILE_FIELD_NAME);
      List<FilePart> files = body.getFiles();
      FilePart file = null;
      if (!files.isEmpty()) file = files.get(0);
      String ret="";
      if (file!=null){
        Map<String, String[]> data=body.asFormUrlEncoded();
        String[] datas=data.get(DATA_FIELD_NAME);
        String[] acl=data.get(ACL_FIELD_NAME);

        /*extract attachedData */
        String dataJson=null;
View Full Code Here

    return ok(prepareResponseToJson(listOfDocs));
  }
 
 
  private static Result postFile() throws  Throwable{
    MultipartFormData  body = request().body().asMultipartFormData();
    if (body==null) return badRequest("missing data: is the body multipart/form-data? Check if it contains boundaries too!");
    FilePart file = body.getFile("file");
    Map<String, String[]> data=body.asFormUrlEncoded();
    String[] meta=data.get("meta");
    String[] name=data.get("name");
    if (name==null || name.length==0 || StringUtils.isEmpty(name[0].trim())) return badRequest("missing name field");
    String ret="";
    if (file!=null){
View Full Code Here

TOP

Related Classes of play.mvc.Http.MultipartFormData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.