wolfboys commented on code in PR #3171:
URL:
https://github.com/apache/incubator-streampark/pull/3171#discussion_r1335085701
##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/interceptor/UploadFileTypeInterceptor.java:
##########
@@ -46,16 +59,35 @@ public boolean preHandle(HttpServletRequest request,
HttpServletResponse respons
multipartFile, "File to upload can't be null. Upload file
failed.");
boolean isJarOrPyFile =
FileUtils.isJarFileType(multipartFile.getInputStream())
- || FileUtils.isPythonFileType(
- multipartFile.getContentType(),
multipartFile.getInputStream());
+ || isPythonFileType(multipartFile.getContentType(),
multipartFile.getInputStream());
ApiAlertException.throwIfFalse(
isJarOrPyFile,
- "Illegal file type, Only support standard jar or py files. Upload
file failed.");
+ "Illegal file type, Only support standard jar files. Upload file
failed.");
}
}
return true;
}
+ public boolean isPythonFileType(String contentType, InputStream input) {
+ if (StringUtils.isBlank(contentType) || input == null) {
+ throw new RuntimeException("The contentType or inputStream can not be
null");
+ }
+ try {
+ return getMimeType(input) == MediaType.TEXT_PLAIN.toString()
Review Comment:
getMimeType(input).equals(MediaType.TEXT_PLAIN.toString())
...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]