Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the bug of bml stored filename #460

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ public List<UploadResult> upload(FormDataMultiPart formDataMultiPart, String use
ResourceHelper resourceHelper = ResourceHelperFactory.getResourceHelper();
List<FormDataBodyPart> files = formDataMultiPart.getFields("file");
List<UploadResult> results = new ArrayList<>();
String resourceId = (String) properties.get("resourceId");
for (FormDataBodyPart p : files) {
InputStream inputStream = p.getValueAs(InputStream.class);
FormDataContentDisposition fileDetail = p.getFormDataContentDisposition();
String fileName = new String(fileDetail.getFileName().getBytes("ISO8859-1"), "UTF-8");
String path = resourceHelper.generatePath(user, fileName, properties);
String path = resourceHelper.generatePath(user, resourceId, properties);
StringBuilder sb = new StringBuilder();
//在upload之前首先应该判断一下这个path是否是已经存在了,如果存在了,抛出异常
boolean isFileExists = resourceHelper.checkIfExists(path, user);
Expand All @@ -99,7 +100,6 @@ public List<UploadResult> upload(FormDataMultiPart formDataMultiPart, String use
if (StringUtils.isNotEmpty(md5String) && size >= 0) {
isSuccess = true;
}
String resourceId = (String) properties.get("resourceId");
Resource resource = Resource.createNewResource(resourceId, user, fileName, properties);
//插入一条记录到resource表
long id = resourceDao.uploadResource(resource);
Expand Down