bowenliang123 commented on code in PR #4144: URL: https://github.com/apache/kyuubi/pull/4144#discussion_r1082677745
########## kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala: ########## @@ -147,6 +163,36 @@ object Utils extends Logging { dir } + /** + * write InputStream to temp file in directory + * @param is inputstream for file + * @param dir dir path for temp file creation + * @param fileName original file name with suffix + * @return created new temp file in dir in file name with random path + */ + def writeToTempFile(is: InputStream, dir: Path, fileName: String): File = { + try { + if (!dir.toFile.exists()) { + dir.toFile.mkdirs() + } + val (prefix, suffix) = fileName.lastIndexOf(".") match { + case i if i > 0 => (fileName.substring(0, i), fileName.substring(i)) + case _ => (fileName, "") + } + val filePath = Paths.get(dir.toString, s"$prefix-${abs(Random.nextInt())}$suffix") Review Comment: Addressed. Turned to using an atomic counter for file name identifier generation instead. -- 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: notifications-unsubscr...@kyuubi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org For additional commands, e-mail: notifications-h...@kyuubi.apache.org