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


Java DiskFileItem類代碼示例

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


DiskFileItem類屬於org.apache.commons.fileupload.disk包,在下文中一共展示了DiskFileItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getObject

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public DiskFileItem getObject ( String command ) throws Exception {

        String[] parts = command.split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + command + " " + Arrays.toString(parts));
        }
    }
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:24,代碼來源:FileUpload1.java

示例2: getObject

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public DiskFileItem getObject ( CmdExecuteHelper cmdHelper ) throws Exception {

        String[] parts = cmdHelper.getCommand().split(";");

        if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
            return copyAndDelete(parts[ 1 ], parts[ 2 ]);
        }
        else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
            return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
        }
        else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
            return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
        }
        else {
            throw new IllegalArgumentException("Unsupported command " + cmdHelper.getCommand() + " " + Arrays.toString(parts));
        }
    }
 
開發者ID:pimps,項目名稱:ysoserial-modified,代碼行數:24,代碼來源:FileUpload1.java

示例3: getFile

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public File[] getFile(String fieldName) {
    List<FileItem> items = files.get(fieldName);

    if (items == null) {
        return null;
    }

    List<File> fileList = new ArrayList<>(items.size());
    for (FileItem fileItem : items) {
        File storeLocation = ((DiskFileItem) fileItem).getStoreLocation();
        if (fileItem.isInMemory() && storeLocation != null && !storeLocation.exists()) {
            try {
                storeLocation.createNewFile();
            } catch (IOException e) {
                LOG.error("Cannot write uploaded empty file to disk: {}", storeLocation.getAbsolutePath(), e);
            }
        }
        fileList.add(storeLocation);
    }

    return fileList.toArray(new File[fileList.size()]);
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:23,代碼來源:JakartaMultiPartRequest.java

示例4: fromRequest

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public static PopupForm fromRequest(String uuid, HttpServletRequest request) {
    String descriptor = request.getParameter("descriptor");
    boolean isOpenCampaign = "open-campaign".equals(request.getParameter("open-campaign"));

    long startTime = "".equals(request.getParameter("start_time")) ? 0 : parseTime(request.getParameter("start_time_selected_datetime"));
    long endTime = "".equals(request.getParameter("end_time")) ? 0 : parseTime(request.getParameter("end_time_selected_datetime"));

    List<String> assignToEids = new ArrayList<String>();
    if (request.getParameter("distribution") != null) {
        for (String user : request.getParameter("distribution").split("[\r\n]+")) {
            if (!user.isEmpty()) {
                assignToEids.add(user);
            }
        }
    }

    Optional<DiskFileItem> templateItem = Optional.empty();
    DiskFileItem dfi = (DiskFileItem) request.getAttribute("template");
    if (dfi != null && dfi.getSize() > 0) {
        templateItem = Optional.of(dfi);
    }

    return new PopupForm(uuid, descriptor, startTime, endTime, isOpenCampaign, assignToEids, templateItem);
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:25,代碼來源:PopupForm.java

示例5: getTextParameter

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
private String getTextParameter(DiskFileItem diskFileItem,
                                String characterEncoding) throws Exception {

    String encoding = diskFileItem.getCharSet();

    if (encoding == null) {
        encoding = characterEncoding;
    }

    String textValue;
    if (encoding == null) {
        textValue = new String(diskFileItem.get());
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }

    return textValue;
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:19,代碼來源:MultipartFormDataBuilder.java

示例6: handle

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
@Override
public void handle(final HttpRequest request,
		final HttpResponse response, final HttpContext context) {

	try {
		final List<FileItem> files = RequestFileHandlingUtilities
				.handleFileUpload(request);
		final HashMap<String, String> fileMap = new HashMap<String, String>();
		for (final FileItem fileItem : files) {
			fileMap.put(fileItem.getName(), Files
					.getCanonicalPath(((DiskFileItem) fileItem)
							.getStoreLocation()));
		}

		response.setEntity(new SerializableEntity(fileMap, false));
		fileItems.addAll(files);
	} catch (Exception e) {
		response.setEntity(new StringEntity("ERROR",
				ContentType.DEFAULT_TEXT));
	}
}
 
開發者ID:pmeisen,項目名稱:gen-server-http-listener,代碼行數:22,代碼來源:TestRequestFileHandlingUtilities.java

示例7: isAvailable

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
/**
 * Determine whether the multipart content is still available. If a temporary
 * file has been moved, the content is no longer available.
 */
protected boolean isAvailable()
{
  // If in memory, it's available.
  if (this.fileItem.isInMemory())
  {
    return true;
  }

  // Check actual existence of temporary file.
  if (this.fileItem instanceof DiskFileItem)
  {
    return ( (DiskFileItem) this.fileItem ).getStoreLocation().exists();
  }

  // Check whether current file size is different than original one.
  return ( this.fileItem.getSize() == this.size );
}
 
開發者ID:terraframe,項目名稱:Runway-SDK,代碼行數:22,代碼來源:MultipartFileParameter.java

示例8: urlForFileItem

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public static String urlForFileItem(FileItem fileItem) throws SAXException {
    // Only a reference to the file is output (xs:anyURI)
    final DiskFileItem diskFileItem = (DiskFileItem) fileItem;
    final String uriExpiringWithRequest;
    if (!fileItem.isInMemory()) {
        // File must exist on disk since isInMemory() returns false
        final File file = diskFileItem.getStoreLocation();
        uriExpiringWithRequest = file.toURI().toString();
    } else {
        // File does not exist on disk, must convert
        // NOTE: Conversion occurs every time this method is called. Not optimal.
        try {
            uriExpiringWithRequest = NetUtils.inputStreamToAnyURI(fileItem.getInputStream(), NetUtils.REQUEST_SCOPE);
        } catch (IOException e) {
            throw new OXFException(e);
        }
    }

    return uriExpiringWithRequest;
}
 
開發者ID:evlist,項目名稱:orbeon-forms,代碼行數:21,代碼來源:RequestGenerator.java

示例9: makePayload

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
    // if thresh < written length, delete outputFile after copying to repository temp file
    // otherwise write the contents to repository temp file
    File repository = new File(repoPath);
    DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
    File outputFile = new File(filePath);
    DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
    OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
    os.write(data);
    Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length);
    Reflections.setFieldValue(diskFileItem, "dfos", dfos);
    Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0);
    return diskFileItem;
}
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:15,代碼來源:FileUpload1.java

示例10: isAvailable

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
	// If in memory, it's available.
	if (this.fileItem.isInMemory()) {
		return true;
	}
	// Check actual existence of temporary file.
	if (this.fileItem instanceof DiskFileItem) {
		return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
	}
	// Check whether current file size is different than original one.
	return (this.fileItem.getSize() == this.size);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:CommonsMultipartFile.java

示例11: getStorageDescription

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
	if (this.fileItem.isInMemory()) {
		return "in memory";
	}
	else if (this.fileItem instanceof DiskFileItem) {
		return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
	}
	else {
		return "on disk";
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:CommonsMultipartFile.java

示例12: isAvailable

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
/**
 * Determine whether the multipart content is still available.
 * If a temporary file has been moved, the content is no longer available.
 */
protected boolean isAvailable() {
    // If in memory, it's available.
    if (this.fileItem.isInMemory()) {
        return true;
    }
    // Check actual existence of temporary file.
    if (this.fileItem instanceof DiskFileItem) {
        return ((DiskFileItem) this.fileItem).getStoreLocation().exists();
    }
    // Check whether current file size is different than original one.
    return (this.fileItem.getSize() == this.size);
}
 
開發者ID:devefx,項目名稱:validator-web,代碼行數:17,代碼來源:CommonsMultipartFile.java

示例13: getStorageDescription

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
/**
 * Return a description for the storage location of the multipart content.
 * Tries to be as specific as possible: mentions the file location in case
 * of a temporary file.
 */
public String getStorageDescription() {
    if (this.fileItem.isInMemory()) {
        return "in memory";
    }
    else if (this.fileItem instanceof DiskFileItem) {
        return "at [" + ((DiskFileItem) this.fileItem).getStoreLocation().getAbsolutePath() + "]";
    }
    else {
        return "on disk";
    }
}
 
開發者ID:devefx,項目名稱:validator-web,代碼行數:17,代碼來源:CommonsMultipartFile.java

示例14: getTextParameter

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public static String getTextParameter(DiskFileItem diskFileItem, String characterEncoding)
        throws Exception {
    String encoding = diskFileItem.getCharSet();
    if (encoding == null) {
        encoding = characterEncoding;
    }
    String textValue;
    if (encoding == null) {
        textValue = new String(diskFileItem.get());
    } else {
        textValue = new String(diskFileItem.get(), encoding);
    }
    return textValue;
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:15,代碼來源:SecurityUIUtil.java

示例15: getFilesystemName

import org.apache.commons.fileupload.disk.DiskFileItem; //導入依賴的package包/類
public String[] getFilesystemName(String fieldName) {
    List<FileItem> items = files.get(fieldName);

    if (items == null) {
        return null;
    }

    List<String> fileNames = new ArrayList<>(items.size());
    for (FileItem fileItem : items) {
        fileNames.add(((DiskFileItem) fileItem).getStoreLocation().getName());
    }

    return fileNames.toArray(new String[fileNames.size()]);
}
 
開發者ID:txazo,項目名稱:struts2,代碼行數:15,代碼來源:JakartaMultiPartRequest.java


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