Details
-
Type:
Sub Task
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.5
-
Component/s: User Experience (UX)
-
Security Level: Public (Public: Anyone can view)
-
Labels:None
-
Rice Module:KRAD
-
Sprint:2.5.0-m3 Sprint 1, 2.5.0-m3 Sprint 2, 2.5.0-m4 Sprint 1, UXI 2.5.0-m4 Sprint 2, UXI 2.5.0-m5 Sprint 1, Core 2.5.0-m5 Sprint 2b
-
KAI Review Status:Not Required
-
KTI Review Status:Not Required
-
Code Review Status:Not Required
-
Include in Release Notes?:Yes
Description
Implement fileUploadGet, fileUploadPost, and fileDeletion (names tbd/discussed)
What is working so far in preliminary tests for dummy get and post feedback from the server, There needs to be some handling of error states as well probably:
@MethodAccessible
@RequestMapping(method = RequestMethod.GET, params = "methodToCall=fileUpload")
public @ResponseBody Map fileUploadGet(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
HttpServletRequest request, HttpServletResponse response)
@MethodAccessible
@RequestMapping(method = RequestMethod.POST, params = "methodToCall=fileUpload")
public @ResponseBody Map fileUploadPost(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result,
MultipartHttpServletRequest request, HttpServletResponse response) {
// TODO actual version would use a name passed to the request
List<MultipartFile> uploadedFiles = request.getFiles("files");
List<FileBase> returnObjects = new ArrayList<FileBase>();
for (MultipartFile uploadedFile: uploadedFiles)
{ FileBase fileObject = new FileBase(uploadedFile); String id = UUID.randomUUID().toString() + "_" + uploadedFile.getName(); // TODO Saving to a db/file system would go here // TODO Generation and setting of thumbnail url (when applicable) and file url would go here fileObject.setId(id); fileObject.setDeleteType("DELETE"); // TODO Form key, cache key, view id needs to be added here (probably) fileObject.setDeleteUrl("?methodToCall=fileDelete"); returnObjects.add(fileObject); }ObjectPropertyUtils.setPropertyValue(uifForm, "files", returnObjects);
Map<String, Object> files = new HashMap<String, Object>();
// TODO actual version would use a name passed to the request
files.put("files", returnObjects);
return files;
}