当前位置: 首页>>代码示例>>Java>>正文


Java CommonsMultipartFile.isEmpty方法代码示例

本文整理汇总了Java中org.springframework.web.multipart.commons.CommonsMultipartFile.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java CommonsMultipartFile.isEmpty方法的具体用法?Java CommonsMultipartFile.isEmpty怎么用?Java CommonsMultipartFile.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.multipart.commons.CommonsMultipartFile的用法示例。


在下文中一共展示了CommonsMultipartFile.isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doClockIn

import org.springframework.web.multipart.commons.CommonsMultipartFile; //导入方法依赖的package包/类
/**
 * 
* @Title: doClockIn 
* @Description: 学生在教师拍照考勤时,没有检测到自己考勤
* @return
* BasicEntityVo<?>
 */
@RequestMapping("/clock-in")
@ResponseBody
public BasicEntityVo<?> doClockIn(String jwAccount, String loginAccount, 
		Double lng, Double lat, @RequestParam("clockinImg")CommonsMultipartFile file) {
	if(StringUtils.isBlank(jwAccount)) {
		return new BasicEntityVo<>(StudentClockInBusinessCode.JW_ACCOUNT_EMPTY[0], StudentClockInBusinessCode.JW_ACCOUNT_EMPTY[1]);
	}
	if(StringUtils.isBlank(loginAccount)) {
		return new BasicEntityVo<>(StudentClockInBusinessCode.LOGIN_ACCOUNT_EMPTY[0], StudentClockInBusinessCode.LOGIN_ACCOUNT_EMPTY[1]);
	}
	if(lng == 0.0 || null == lng || lat == 0.0 || null == lat) {
		return new BasicEntityVo<>(StudentClockInBusinessCode.LNG_LAT_EMPTY[0], StudentClockInBusinessCode.LNG_LAT_EMPTY[1]);
	}
	if(file.isEmpty()) {
		return new BasicEntityVo<>(StudentClockInBusinessCode.BUSSINESS_IMAGE_EMPTY[0], StudentClockInBusinessCode.BUSSINESS_IMAGE_EMPTY[1]);
	}
	
	return clockinAsStudentService.clockin(jwAccount, loginAccount, lng, lat, file);
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:27,代码来源:ClockinAsStudentController.java

示例2: setAttachment

import org.springframework.web.multipart.commons.CommonsMultipartFile; //导入方法依赖的package包/类
@RequestMapping(value = "/attach/{id}", method = RequestMethod.POST)
public String setAttachment(@PathVariable("id") Long activityId,
                          @RequestParam("file") CommonsMultipartFile attachment,
                          WebRequest webRequest) {
    IssueAttachmentFileUtil issueAttachmentFileUtil = new IssueAttachmentFileUtil();

    Activity activity = activityService.find(activityId);

    issueAttachmentFileUtil.deleteIfExcist(activity, servletContext);

    activity.setFileName(attachment.getOriginalFilename());
    activity = activityService.save(activity);

    if (!attachment.isEmpty() && activity != null) {

        issueAttachmentFileUtil.saveActivityAttachment(activity, attachment, servletContext);
    }

    return activity.getFileName();
}
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:21,代码来源:ActivityRestControllerImpl.java

示例3: convertFilesToMap

import org.springframework.web.multipart.commons.CommonsMultipartFile; //导入方法依赖的package包/类
/**
 * This method converts the uploaded files into a map where the key is the
 * file name and the value is the file content.
 */
public synchronized  static Map<String, String> convertFilesToMap(CommonsMultipartFile[] fileInputList ) {
    Map<String, String> fileMap = new LinkedHashMap<String, String>();
    CommonsMultipartFile tmpMultiFile;
    String tmpCharset;
    fileNameCounterMap.clear();
    for (int i = 0; i < fileInputList.length; i++) {
        tmpMultiFile = fileInputList[i];
        try {
            if (tmpMultiFile != null && !tmpMultiFile.isEmpty() && tmpMultiFile.getInputStream() != null) {
                tmpCharset = CrawlUtils.extractCharset(tmpMultiFile.getInputStream());
                fileMap.put(
                        getFileName(tmpMultiFile.getOriginalFilename()),
                        tmpMultiFile.getFileItem().getString(tmpCharset));
            }
        } catch (IOException e) {}
    }
    return fileMap;
}
 
开发者ID:Tanaguru,项目名称:Tanaguru,代码行数:23,代码来源:UploadAuditSetUpCommandHelper.java

示例4: documentModificarPost

import org.springframework.web.multipart.commons.CommonsMultipartFile; //导入方法依赖的package包/类
@RequestMapping(value="/{expedientId}/documentAdjuntar", method = RequestMethod.POST)
public String documentModificarPost(
		HttpServletRequest request,
		@PathVariable Long expedientId,
		@RequestParam(value = "accio", required = true) String accio,
		@ModelAttribute DocumentExpedientCommand command, 
		@RequestParam(value = "arxiu", required = false) final CommonsMultipartFile arxiu,	
		@RequestParam(value = "processInstanceId", required = true) String processInstanceId,
		BindingResult result, 
		SessionStatus status, 
		Model model) {
	try {
		new DocumentModificarValidator().validate(command, result);
		if (result.hasErrors() || arxiu == null || arxiu.isEmpty()) {
        	if (arxiu == null || arxiu.isEmpty()) {
	        	MissatgesHelper.error(request, getMessage(request, "error.especificar.document"));				        	
	        }
    		model.addAttribute("processInstanceId", processInstanceId);
        	return "v3/expedientDocumentNou";
        }
		
		byte[] contingutArxiu = IOUtils.toByteArray(arxiu.getInputStream());
		String nomArxiu = arxiu.getOriginalFilename();
		command.setNomArxiu(nomArxiu);
		command.setContingut(contingutArxiu);

		expedientService.crearModificarDocument(expedientId, processInstanceId, null, command.getNom(), command.getNomArxiu(), command.getDocId(), command.getContingut(), command.getData());
		MissatgesHelper.success(request, getMessage(request, "info.document.guardat") );
       } catch (Exception ex) {
		logger.error("No s'ha pogut crear el document: expedientId: " + expedientId, ex);
		MissatgesHelper.error(request, getMessage(request, "error.proces.peticio") + ": " + ex.getLocalizedMessage());
       }
	return modalUrlTancar(false);
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:35,代码来源:ExpedientDocumentController.java

示例5: uploadImage

import org.springframework.web.multipart.commons.CommonsMultipartFile; //导入方法依赖的package包/类
/**
 * Upload image.
 *
 * @param file the file
 * @param principal the principal
 * @return the map< string,? extends object>
 */
@RequestMapping(value = "/document/upload", method = RequestMethod.POST)
public @ResponseBody Map<String, ? extends Object> uploadImage(@RequestParam("file") CommonsMultipartFile file
		, Principal principal) {
	
	SasUser sasUser = JsonOutput.readSasUser(principal);
	
	if (!file.isEmpty()) {
		if (debug) {
			System.out.println(
					"file: " + file + 
					", name: " + file.getName() +
					", contentType: " + file.getContentType() +
					", originalFilename: " + file.getOriginalFilename() +
					", extension: " + FilenameUtils.getExtension(file.getOriginalFilename()) +
					", size: " + file.getSize() +
					", defaultpath: " + filesSettings.getDocumentsDefaultPath()
			);
		}

		try {
			byte[] bytes = file.getBytes();
			
			
			return JsonOutput.mapSuccess();
		} catch (Exception e) {
			return JsonOutput.mapError( "Failed to upload " + file.getOriginalFilename() + " => " + e.getMessage() );
		}
	} else {
		return JsonOutput.mapError( "You failed to upload " + file.getOriginalFilename() + " because the file was empty." );
	}
}
 
开发者ID:gleb619,项目名称:hotel_shop,代码行数:39,代码来源:DocumentsController.java


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