• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DefaultMultipartHttpServletRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest的典型用法代码示例。如果您正苦于以下问题:Java DefaultMultipartHttpServletRequest类的具体用法?Java DefaultMultipartHttpServletRequest怎么用?Java DefaultMultipartHttpServletRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultMultipartHttpServletRequest类属于org.springframework.web.multipart.support包,在下文中一共展示了DefaultMultipartHttpServletRequest类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: upload

import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; //导入依赖的package包/类
@PostMapping("file")
public String upload(@RequestParam("file") MultipartFile file, MultipartRequest multipartRequest) {
    System.out.println(file);
    DefaultMultipartHttpServletRequest request = (DefaultMultipartHttpServletRequest) multipartRequest;
    String fileName = request.getParameter("fileName");
    StringBuilder stringBuilder = new StringBuilder("fileName" + " : " + fileName);
    try {
        InputStream inputStream = file.getInputStream();
        InputStreamReader in = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(in);
        bufferedReader.lines().forEach(stringBuilder::append);
        IOUtils.closeQuietly(inputStream, in, bufferedReader);
    } catch (IOException e) {
        e.printStackTrace();
    }


    return stringBuilder.toString();
}
 
开发者ID:ismartx,项目名称:summer,代码行数:20,代码来源:UserController.java


示例2: addImage

import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; //导入依赖的package包/类
@RequestMapping(value = IMAGES, method = POST)
public String addImage(@RequestParam("image") MultipartFile file, DefaultMultipartHttpServletRequest request, Locale locale) throws IOException {

    // NOTE: Checking user rights and CSRF-Token needs to be done here because HttpUserService gains
    // NOTE org.eclipse.jetty.server.Request which is not able to handle parameters at multipartrequests

    User currentUser = userService.getCurrentUser(false);
    if (!currentUser.isOm()) {
        throw new AccessDeniedException("Om rights required");
    }

    userService.verifyCSRFToken(request);

    imageFinder.validateAndSaveFile(file);
    return redirectWithMessage(request.getHeader("Referer"), RequestMessage.EDITOR_UPLOAD_IMAGE, request);
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:17,代码来源:InfoTextController.java


示例3: runReporting

import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; //导入依赖的package包/类
@RequestMapping(value = "/runReporting", method = RequestMethod.POST)
@ResponseBody
public void runReporting(final HttpServletRequest req, final HttpServletResponse resp) {
	logger.info("Start processing the run reporting web service");
	String respStr = WebServiceUtil.EMPTY_STRING;
	try {
		if (req instanceof DefaultMultipartHttpServletRequest) {

			InputStream instream = null;
			final DefaultMultipartHttpServletRequest multiPartRequest = (DefaultMultipartHttpServletRequest) req;
			final MultiValueMap<String, MultipartFile> fileMap = multiPartRequest.getMultiFileMap();
			for (final String fileName : fileMap.keySet()) {
				final MultipartFile multiPartFile = multiPartRequest.getFile(fileName);
				instream = multiPartFile.getInputStream();
				final Source source = XMLUtil.createSourceFromStream(instream);
				final ReportingOptions option = (ReportingOptions) batchSchemaDao.getJAXB2Template().getJaxb2Marshaller()
						.unmarshal(source);
				final String installerPath = option.getInstallerPath();
				if (installerPath == null || installerPath.isEmpty() || !installerPath.toLowerCase().contains("build.xml")) {
					respStr = "Improper input to server. Installer path not specified or it does not contain the build.xml path.";
				} else {
					logger.info("synchronizing the database");
					reportingService.syncDatabase(installerPath);
					break;
				}
			}

		} else {
			respStr = "Improper input to server. Expected multipart request. Returning without processing the results.";
		}
	} catch (final XmlMappingException xmle) {
		respStr = "Error in mapping input XML in the desired format. Please send it in the specified format. Detailed exception is "
				+ xmle;
	} catch (final Exception e) {
		respStr = "Internal Server error.Please check logs for further details." + e;
	}

	if (!respStr.isEmpty()) {
		try {
			resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, respStr);
		} catch (final IOException ioe) {

		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:46,代码来源:EphesoftWebServiceAPI.java


示例4: runReporting

import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; //导入依赖的package包/类
/**
 * To run Reporting.
 * @param req {@link HttpServletRequest}
 * @param resp {@link HttpServletResponse}
 */
@RequestMapping(value = "/runReporting", method = RequestMethod.POST)
@ResponseBody
public void runReporting(final HttpServletRequest req, final HttpServletResponse resp) {
	LOGGER.info("Start processing the run reporting web service");
	String respStr = WebServiceUtil.EMPTY_STRING;
	try {
		if (req instanceof DefaultMultipartHttpServletRequest) {

			InputStream instream = null;
			final DefaultMultipartHttpServletRequest multiPartRequest = (DefaultMultipartHttpServletRequest) req;
			final MultiValueMap<String, MultipartFile> fileMap = multiPartRequest.getMultiFileMap();
			for (final String fileName : fileMap.keySet()) {
				final MultipartFile multiPartFile = multiPartRequest.getFile(fileName);
				instream = multiPartFile.getInputStream();
				final Source source = XMLUtil.createSourceFromStream(instream);
				final ReportingOptions option = (ReportingOptions) batchSchemaDao.getJAXB2Template().getJaxb2Marshaller()
						.unmarshal(source);
				final String installerPath = option.getInstallerPath();
				if (installerPath == null || installerPath.isEmpty()
						|| !installerPath.toLowerCase(Locale.getDefault()).contains(WebServiceUtil.BUILD_XML)) {
					respStr = "Improper input to server. Installer path not specified or it does not contain the build.xml path.";
				} else {
					LOGGER.info("synchronizing the database");
					reportingService.syncDatabase(installerPath);
					break;
				}
			}

		} else {
			respStr = IMPROPER_INPUT_TO_SERVER;
			LOGGER.error(SERVER_ERROR_MSG + respStr);
		}
	} catch (final XmlMappingException xmle) {
		respStr = ERROR_IN_MAPPING_INPUT + xmle;
		LOGGER.error(SERVER_ERROR_MSG + respStr);
	} catch (final Exception e) {
		respStr = INTERNAL_SERVER_ERROR + e;
		LOGGER.error(SERVER_ERROR_MSG + respStr);
	}

	if (!respStr.isEmpty()) {
		try {
			resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, respStr);
			LOGGER.error(SERVER_ERROR_MSG + respStr);
		} catch (final IOException ioe) {
			LOGGER.info(ERROR_WHILE_SENDING_ERROR_RESPONSE_TO_CLIENT + ioe, ioe);
		}
	}
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:55,代码来源:EphesoftWebServiceAPI.java


示例5: validateInputAndPerformExtraction

import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest; //导入依赖的package包/类
private String validateInputAndPerformExtraction(final HttpServletRequest req, final HttpServletResponse resp,
		final String respStr, final String workingDir, final DefaultMultipartHttpServletRequest multiPartRequest,
		final Set<String> fileNameSet, final String batchClassIdentifier, final String documentType, final String hocrFileName)
		throws IOException, FileNotFoundException, DCMAException {
	InputStream instream;
	OutputStream outStream;
	String respStrLocal = respStr;
	try {
		BatchClass batchClass = bcService.getBatchClassByIdentifier(batchClassIdentifier);
		if (batchClass == null) {
			respStrLocal = "Please enter valid batch class identifier";
		} else {
			Set<String> loggedInUserRole = getUserRoles(req);
			if (!isBatchClassViewableToUser(batchClassIdentifier, loggedInUserRole, isSuperAdmin(req))) {
				respStrLocal = USER_NOT_AUTHORIZED_TO_VIEW_THE_BATCH_CLASS + batchClassIdentifier;
				LOGGER.error(SERVER_ERROR_MSG + respStrLocal);
			} else {
				BatchPlugin regularRegexPlugin = batchClassPPService.getPluginProperties(batchClassIdentifier,
						"REGULAR_REGEX_EXTRACTION");
				if (regularRegexPlugin == null || regularRegexPlugin.getPropertiesSize() == 0) {
					respStrLocal = "Fuzzy DB plugin is not configured for batch class : " + batchClassIdentifier
							+ " . Please select proper batch class";
					LOGGER.error(SERVER_ERROR_MSG + respStrLocal);
				}
				for (final String fileName : fileNameSet) {
					if (fileName.equalsIgnoreCase(hocrFileName)) {
						LOGGER.info("hocr file name found : " + hocrFileName);
						final MultipartFile multiPartFile = multiPartRequest.getFile(fileName);
						instream = multiPartFile.getInputStream();
						final File file = new File(workingDir + File.separator + fileName);
						outStream = new FileOutputStream(file);
						final byte[] buf = new byte[WebServiceUtil.bufferSize];
						int len = instream.read(buf);
						while (len > 0) {
							outStream.write(buf, 0, len);
							len = instream.read(buf);
						}
						break;
					}
				}
				final File hocrFile = new File(workingDir + File.separator + hocrFileName);
				if (hocrFile.exists()) {
					respStrLocal = performRegexExtraction(resp, workingDir, hocrFile.getAbsolutePath(), batchClassIdentifier,
							documentType);
				}
			}
		}
	} catch (Exception exception) {
		LOGGER.error("Error occurred while extracting fields using regular regex extarction.");
		throw new DCMAException(exception.getMessage(), exception);
	}
	return respStrLocal;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:54,代码来源:EphesoftWebServiceAPI.java



注:本文中的org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaxonSet类代码示例发布时间:2022-05-22
下一篇:
Java PersistenceProviderResolverHolder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap