本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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);
}
示例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." );
}
}