本文整理汇总了Java中org.apache.commons.fileupload.ParameterParser类的典型用法代码示例。如果您正苦于以下问题:Java ParameterParser类的具体用法?Java ParameterParser怎么用?Java ParameterParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterParser类属于org.apache.commons.fileupload包,在下文中一共展示了ParameterParser类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCharSet
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* Returns the content charset passed by the agent or <code>null</code> if
* not defined.
*
* @return The content charset passed by the agent or <code>null</code> if
* not defined.
*/
public String getCharSet() {
ParameterParser parser = new ParameterParser();
parser.setLowerCaseNames(true);
// Parameter parser can handle null input
Map<String, String> params = parser.parse(getContentType(), ';');
return params.get("charset");
}
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:15,代码来源:DiskFileItem.java
示例2: upload
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* ueditor上传文件
*
* @return 上传结果
* @throws IOException 文件上传错误
*/
@RequestMapping(method = RequestMethod.POST, consumes = "multipart/form-data")
@ApiOperation("上传文件")
public String upload(@RequestParam(value = "upfile", required = false) MultipartFile file,HttpServletRequest request) throws IOException {
String fileName = file.getOriginalFilename();
String contentType = Optional.ofNullable(request)
.orElseThrow(UnsupportedOperationException::new)
.getContentType();
ParameterParser parser = new ParameterParser();
Map<String, String> params = parser.parse(contentType, ';');
if (params.get("charset") == null) {
try {
fileName = new String(file.getOriginalFilename().getBytes("ISO-8859-1"), "utf-8");
} catch (@SuppressWarnings("all") UnsupportedEncodingException ignore) {
}
}
String suffix = FileType.getSuffixByFilename(fileName);
String path = fileService.saveStaticFile(file.getInputStream(), System.currentTimeMillis() + suffix);
State state = new BaseState(true);
state.putInfo("size", file.getSize());
state.putInfo("title",fileName);
state.putInfo("url", path);
state.putInfo("type", suffix);
state.putInfo("original",fileName);
return state.toJSONString();
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:33,代码来源:UeditorController.java
示例3: getFileName
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
private String getFileName(String pContentDisposition) {
String fileName = null;
if (pContentDisposition != null) {
String cdl = pContentDisposition.toLowerCase();
if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) {
ParameterParser parser = new ParameterParser();
parser.setLowerCaseNames(true);
// Parameter parser can handle null input
@SuppressWarnings("unchecked")
Map<String, String> params = parser.parse(pContentDisposition, ';');
// 解决类似Flash上传更改了filename 为 fname 的多客户端支持
for (String key : getFileNameKey()) {
fileName = StringUtils.trimToNull(params.get(key));
if (fileName != null) {
break;
}
}
}
}
return fileName;
}
开发者ID:solmix,项目名称:wmix,代码行数:28,代码来源:ServletFileUpload.java
示例4: getCharSet
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* Returns the content charset passed by the agent or <code>null</code> if
* not defined.
*
* @return The content charset passed by the agent or <code>null</code> if
* not defined.
*/
public String getCharSet()
{
ParameterParser parser = new ParameterParser();
parser.setLowerCaseNames(true);
// Parameter parser can handle null input
Map params = parser.parse(getContentType(), ';');
return (String) params.get("charset");
}
开发者ID:roguexz,项目名称:gae-java-template,代码行数:16,代码来源:InMemoryFileItem.java
示例5: upload
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* 上传单个文件
*
* @param file 上传文件
* @return 上传结果
*/
@PostMapping(value = "/upload")
@AccessLogger("上传单个文件")
@Authorize(action = "upload", description = "上传文件")
public ResponseMessage<FileInfoEntity> upload(@RequestPart("file") MultipartFile file) {
List<FileInfoEntity> fileInfoList = new LinkedList<>();
Authentication authentication = Authentication.current().orElse(null);
String creator = authentication == null ? null : authentication.getUser().getId();
if (file.isEmpty()) {
return ResponseMessage.ok();
}
String fileName = file.getOriginalFilename();
String contentType = Optional.ofNullable(WebUtil.getHttpServletRequest())
.orElseThrow(UnsupportedOperationException::new)
.getContentType();
ParameterParser parser = new ParameterParser();
Map<String, String> params = parser.parse(contentType, ';');
if (params.get("charset") == null) {
try {
fileName = new String(file.getOriginalFilename().getBytes("ISO-8859-1"), "utf-8");
} catch (@SuppressWarnings("all") UnsupportedEncodingException ignore) {
}
}
if (logger.isInfoEnabled()) {
logger.info("start write file:{}", fileName);
}
FileInfoEntity fileInfo;
try {
fileInfo = fileService.saveFile(file.getInputStream(), fileName, file.getContentType(), creator);
} catch (IOException e) {
throw new BusinessException("save file error", e);
}
fileInfoList.add(fileInfo);
return ResponseMessage.ok(fileInfo)
.include(FileInfoEntity.class, FileInfoEntity.id,
FileInfoEntity.name,
FileInfoEntity.md5,
FileInfoEntity.size,
FileInfoEntity.type);
}
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:47,代码来源:FileController.java
示例6: parse
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* @brief 解析请求的get信息
* @param request Http请求
* @return 名称与值的Map集合
* @throws IOException
* @warning 需保证是post请求且不是multipart的。
*/
public Map<String, String> parse(HttpRequest request) {
ParameterParser parser = new ParameterParser();
parser.setLowerCaseNames(true);
return parser.parse(getContent(request), '&');
}
开发者ID:taugin,项目名称:cim,代码行数:13,代码来源:HttpGetParser.java
示例7: parse
import org.apache.commons.fileupload.ParameterParser; //导入依赖的package包/类
/**
* @brief 解析请求的post信息
* @param request Http请求
* @return 名称与值的Map集合
* @throws IOException
* @warning 需保证是post请求且不是multipart的。
*/
public Map<String, String> parse(HttpRequest request) throws IOException {
ParameterParser parser = new ParameterParser();
parser.setLowerCaseNames(true);
return parser.parse(getContent(request), '&');
}
开发者ID:taugin,项目名称:cim,代码行数:13,代码来源:HttpPostParser.java
注:本文中的org.apache.commons.fileupload.ParameterParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论