當前位置: 首頁>>代碼示例>>Java>>正文


Java DiskFileItemFactory.setFileCleaningTracker方法代碼示例

本文整理匯總了Java中org.apache.commons.fileupload.disk.DiskFileItemFactory.setFileCleaningTracker方法的典型用法代碼示例。如果您正苦於以下問題:Java DiskFileItemFactory.setFileCleaningTracker方法的具體用法?Java DiskFileItemFactory.setFileCleaningTracker怎麽用?Java DiskFileItemFactory.setFileCleaningTracker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.fileupload.disk.DiskFileItemFactory的用法示例。


在下文中一共展示了DiskFileItemFactory.setFileCleaningTracker方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseMultipartWithCommonsFileUpload

import org.apache.commons.fileupload.disk.DiskFileItemFactory; //導入方法依賴的package包/類
private Collection<Part> parseMultipartWithCommonsFileUpload(HttpServletRequest request) throws IOException {
  if (sharedFileItemFactory.get() == null) {
    // Not a big deal if two threads actually set this up
    DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(
        1 << 16, (File) servletContext.getAttribute("javax.servlet.context.tempdir"));
    fileItemFactory.setFileCleaningTracker(
        FileCleanerCleanup.getFileCleaningTracker(servletContext));
    sharedFileItemFactory.compareAndSet(null, fileItemFactory);
  }

  try {
    return new ServletFileUpload(sharedFileItemFactory.get()).parseRequest(request)
        .stream().map(FileItemPart::new).collect(Collectors.toList());
  } catch (FileUploadException e) {
    throw new IOException(e.getMessage());
  }
}
 
開發者ID:oncewang,項目名稱:oryx2,代碼行數:18,代碼來源:AbstractOryxResource.java

示例2: getDefaultFileItemFactory

import org.apache.commons.fileupload.disk.DiskFileItemFactory; //導入方法依賴的package包/類
private static FileItemFactory getDefaultFileItemFactory(final int threshold)
{
    final DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory();
    diskFileItemFactory.setFileCleaningTracker( new FileCleaningTracker() );
    diskFileItemFactory.setSizeThreshold( threshold );
    return diskFileItemFactory;
}
 
開發者ID:Sauilitired,項目名稱:Kvantum,代碼行數:8,代碼來源:KvantumFileUpload.java

示例3: getFileUploadComponent

import org.apache.commons.fileupload.disk.DiskFileItemFactory; //導入方法依賴的package包/類
private ServletFileUpload getFileUploadComponent()
{
    DiskFileItemFactory dif=new DiskFileItemFactory();

    if(factorySizeThreshold!=DEFAULT_SIZE_THRESHOLD)
    {
        dif.setSizeThreshold(factorySizeThreshold);
    }
    if(factoryRepository!=null)
    {
        dif.setRepository(new File(factoryRepository));
    }
    if(factoryCleaningTracker!=null)
    {
        dif.setFileCleaningTracker(factoryCleaningTracker);
    }

    ServletFileUpload sfu=new ServletFileUpload(dif);

    if(sizeMax!=NO_LIMIT_SIZE_MAX)
    {
        sfu.setSizeMax(sizeMax);
    }
    if(fileSizeMax!=NO_LIMIT_FILE_SIZE_MAX)
    {
        sfu.setFileSizeMax(fileSizeMax);
    }
    if(servletHeaderencoding!=null)
    {
        sfu.setHeaderEncoding(servletHeaderencoding);
    }
    if(servletProgressListener!=null)
    {
        sfu.setProgressListener(servletProgressListener);
    }

    return sfu;
}
 
開發者ID:ProteanBear,項目名稱:ProteanBear_Java,代碼行數:39,代碼來源:FileUploader.java

示例4: createFileUpload

import org.apache.commons.fileupload.disk.DiskFileItemFactory; //導入方法依賴的package包/類
private ServletFileUpload createFileUpload(String encoding) {
	DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(_sizeThreshold, _tempDir);
	diskFileItemFactory.setFileCleaningTracker(_fileCleaningTracker);

	ServletFileUpload fileUpload = new ServletFileUpload(diskFileItemFactory);
	fileUpload.setHeaderEncoding(encoding);
	fileUpload.setFileSizeMax(_fileSizeMax);
	fileUpload.setSizeMax(_sizeMax);
	
	//_fileUploadEncodingMap.put(fileUpload.getHeaderEncoding(), fileUpload);
	
	return fileUpload;
}
 
開發者ID:SalamaSoft,項目名稱:REST-framework,代碼行數:14,代碼來源:FileUploadSupport.java

示例5: doPost

import org.apache.commons.fileupload.disk.DiskFileItemFactory; //導入方法依賴的package包/類
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    boolean isMultipart = ServletFileUpload.isMultipartContent(req);
    HttpSession session = req.getSession(false);
    Integer userId = (int)session.getAttribute("id_user");
    Integer orderId = (int)session.getAttribute("currentOrder");
    PrintWriter out = resp.getWriter();
    JsonObject jsonObject = new JsonObject();

    if(isMultipart && userId != -1 && orderId != -1){
        // Create a factory for disk-based file items
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // Configure a repository (to ensure a secure temp location is used)
        ServletContext servletContext = this.getServletConfig().getServletContext();

        FileCleaningTracker tracker = FileCleanerCleanup.getFileCleaningTracker(servletContext);
        factory.setFileCleaningTracker(tracker);
        File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
        factory.setRepository(repository);

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);

        try {
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem imageFile : items){
                byte[] imageByte = imageFile.get();
                Order order = new Order();
                order.setId(orderId);
                Image image = new Image();
                image.setDataimage(imageByte);
                image.setOrder(order);
                new ImageDBManager().create(image);
            }
            jsonObject.addProperty("success", true);

        } catch (FileUploadException e) {
            jsonObject.addProperty("success", false);
            e.printStackTrace();
        }
    } else {
        jsonObject.addProperty("success", false);
    }

    out.append(jsonObject.toString());
    out.flush();


}
 
開發者ID:SergeyZhernovoy,項目名稱:Java-education,代碼行數:52,代碼來源:ImageServlet.java


注:本文中的org.apache.commons.fileupload.disk.DiskFileItemFactory.setFileCleaningTracker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。