Examples of CommonsMultipartFile


Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            buildingObjectManager.saveBuildingObject(buildingObject);
            saveMessage(request, getText("objectPhoto.deleted", locale));
        } else {
            MultipartHttpServletRequest multipartRequest =
                    (MultipartHttpServletRequest) request;
            CommonsMultipartFile file =
                    (CommonsMultipartFile) multipartRequest.getFile("file");
            if (file.getSize() > 0) {
                String fileName = ImageUtil.getUniqueJPEGFile(request);
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                fileOutputStream.write(file.getBytes());
                fileOutputStream.close();
                InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 400, 400);

                fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                byte[] bufer = new byte[62000];
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            saveMessage(request, getText("hint.deleted", locale));
        } else {

            MultipartHttpServletRequest multipartRequest =
                    (MultipartHttpServletRequest) request;
            CommonsMultipartFile file =
                    (CommonsMultipartFile) multipartRequest.getFile("file");
            if (file.getSize() > 0) {
                String fileName = ImageUtil.getUniqueJPEGFile(request);
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                fileOutputStream.write(file.getBytes());
                fileOutputStream.close();
                InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 200, 200);

                fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                byte[] bufer = new byte[62000];
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

        CompanyLicense companyLicense = (CompanyLicense) command;

        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("photo.file");


        if (companyLicense.getLicenseId() != null) {
            String comment = companyLicense.getPhoto().getComment();
            companyLicense = companyLicenseManager.getById(companyLicense.getLicenseId());
            Photo photo = photoManager.getByIdPhoto(companyLicense.getPhoto().getPhotoId());
            photo.setComment(comment);            
            photoManager.update(photo, file, FileHelper.getCurrentPath(request),400,400);
            companyLicenseManager.update(companyLicense);
            return new ModelAndView("redirect:/companyLicenseList.html");

        } else {
            if (file.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(file, FileHelper.getCurrentPath(request),400,400);
                photo.setComment(companyLicense.getPhoto().getComment());
                companyLicense.setPhoto(photo);
            }
            companyLicenseManager.insert(companyLicense);
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            return showForm(request, response, errors);
        }

        MultipartHttpServletRequest multipartRequest =
                (MultipartHttpServletRequest) request;
        CommonsMultipartFile file =
                (CommonsMultipartFile) multipartRequest.getFile("file");

        // the directory to upload to
        String uploadDir =
                getServletContext().getRealPath("/resources") + "/" +
                        request.getRemoteUser() + "/";

        // Create the directory if it doesn't exist
        File dirPath = new File(uploadDir);

        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }

        //retrieve the file data
        InputStream stream = file.getInputStream();

        //write the file to the file specified
        OutputStream bos =
                new FileOutputStream(uploadDir + file.getOriginalFilename());
        int bytesRead = 0;
        byte[] buffer = new byte[8192];

        while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
            bos.write(buffer, 0, bytesRead);
        }

        bos.close();

        //close the stream
        stream.close();

        // place the data into the request for retrieval on next page
        request.setAttribute("friendlyName", fileUpload.getName());
        request.setAttribute("fileName", file.getOriginalFilename());
        request.setAttribute("contentType", file.getContentType());
        request.setAttribute("size", file.getSize() + " bytes");
        request.setAttribute("location",
                dirPath.getAbsolutePath() + Constants.FILE_SEP +
                        file.getOriginalFilename());

        String link =
                request.getContextPath() + "/resources" + "/" +
                        request.getRemoteUser() + "/";

        request.setAttribute("link", link + file.getOriginalFilename());

        return new ModelAndView(getSuccessView());
    }
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            }

            MultipartHttpServletRequest multipartRequest =
                    (MultipartHttpServletRequest) request;
            CommonsMultipartFile file =
                    (CommonsMultipartFile) multipartRequest.getFile("file");
            if (file.getSize() > 0) {
                String fileName = ImageUtil.getUniqueJPEGFile(request);
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                fileOutputStream.write(file.getBytes());
                fileOutputStream.close();
                InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 200, 200);

                fileOutputStream = new FileOutputStream(fileName);
                byte[] bufer = new byte[62000];
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            Integer id = (Integer) Integer.parseInt(request.getSession().getAttribute("objectId").toString());
            ObjectInspection objectInspection = objectInspectionManager.getObjectInspectionBy(id);

            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");


            if (photo.getPhotoId() != null) {
              
                if (request.getSession().getAttribute("type").equals("oborudovanieList")) {
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

public class UploadFileUtil {

  public static String uploadFile(HttpServletRequest request, String uploadDir) throws IOException
  {
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");
     
    File dirPath = new File(uploadDir);
    if(!dirPath.exists())
    {
      dirPath.mkdirs();
    }
   
    InputStream stream = file.getInputStream();
    OutputStream bos = new FileOutputStream(uploadDir + file.getOriginalFilename());
    int bytesRead = 0;
    byte buffer[] = new byte[8192];
    while((bytesRead = stream.read(buffer, 0, 8192)) != -1)
    {
      bos.write(buffer, 0, bytesRead);
    }
    bos.close();     
    stream.close();
   
    String path = uploadDir + file.getOriginalFilename();
    return path;
  }
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            return "uploadForm";
        }

        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");

        // the directory to upload to
        String uploadDir = getServletContext().getRealPath("/resources") + "/" + request.getRemoteUser() + "/";

        // Create the directory if it doesn't exist
        File dirPath = new File(uploadDir);

        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }

        //retrieve the file data
        InputStream stream = file.getInputStream();

        //write the file to the file specified
        OutputStream bos = new FileOutputStream(uploadDir + file.getOriginalFilename());
        int bytesRead;
        byte[] buffer = new byte[8192];

        while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
            bos.write(buffer, 0, bytesRead);
        }

        bos.close();

        //close the stream
        stream.close();

        // place the data into the request for retrieval on next page
        request.setAttribute("friendlyName", fileUpload.getName());
        request.setAttribute("fileName", file.getOriginalFilename());
        request.setAttribute("contentType", file.getContentType());
        request.setAttribute("size", file.getSize() + " bytes");
        request.setAttribute("location", dirPath.getAbsolutePath() + Constants.FILE_SEP + file.getOriginalFilename());

        String link = request.getContextPath() + "/resources" + "/" + request.getRemoteUser() + "/";
        request.setAttribute("link", link + file.getOriginalFilename());

        return getSuccessView();
    }
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

            constructionDefect.setDefectParameters(parameters);


            MultipartHttpServletRequest multipartRequest =
                    (MultipartHttpServletRequest) request;
            CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");
            if (file.getSize() > 0) {
                String fileName = ImageUtil.getUniqueJPEGFile(request);
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                fileOutputStream.write(file.getBytes());
                fileOutputStream.close();
                InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 400, 400);

                fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                byte[] bufer = new byte[62000];
View Full Code Here

Examples of org.springframework.web.multipart.commons.CommonsMultipartFile

        }


        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        CommonsMultipartFile ffile = (CommonsMultipartFile) multipartRequest.getFile("firstPhoto.file");
        CommonsMultipartFile sfile = (CommonsMultipartFile) multipartRequest.getFile("secondPhoto.file");

        if (pipeLineElementDefect.getDefectId() != null) {
            pipeLineElementDefect = pipeLineElementDefectManager.getPipeLineElementDefectById(pipeLineElementDefect.getDefectId());
            Photo photo = photoManager.getByIdPhoto(pipeLineElementDefect.getFirstPhoto().getPhotoId());
            photoManager.update(photo, ffile, FileHelper.getCurrentPath(request));
            photo = photoManager.getByIdPhoto(pipeLineElementDefect.getSecondPhoto().getPhotoId());
            photoManager.update(photo, sfile, FileHelper.getCurrentPath(request));
            pipeLineElementDefectManager.update(pipeLineElementDefect);
            return new ModelAndView("redirect:/pipeLineElementDefectList.html?objectId=" + request.getParameter("objectId") + "&detailType=" + request.getParameter("detailType") + "&pipeElementId=" + elementId);
        } else {

            if (ffile != null && ffile.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(ffile, FileHelper.getCurrentPath(request));
                pipeLineElementDefect.setFirstPhoto(photo);
            } else {
                Photo photo = new Photo();
                photo.setWayToPhoto("no photo");
                photoManager.insert(photo);
                pipeLineElementDefect.setFirstPhoto(photo);
            }
            if (sfile != null && sfile.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(sfile, FileHelper.getCurrentPath(request));
                pipeLineElementDefect.setSecondPhoto(photo);
            } else {
                Photo photo = new Photo();
                photo.setWayToPhoto("no photo");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.