diff --git a/.DS_Store b/.DS_Store index 95d9c98..a97af01 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000..a42de40 Binary files /dev/null and b/.github/.DS_Store differ diff --git a/.github/workflows/.DS_Store b/.github/workflows/.DS_Store new file mode 100644 index 0000000..63353ce Binary files /dev/null and b/.github/workflows/.DS_Store differ diff --git a/.github/workflows/aws-codeguru-reviewer.yml b/.github/workflows/aws-codeguru-reviewer.yml new file mode 100644 index 0000000..37bac9d --- /dev/null +++ b/.github/workflows/aws-codeguru-reviewer.yml @@ -0,0 +1,44 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: + push: + branches: [main, mingTest] + pull_request: + branches: [main] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - run: echo "TEST secret ${{ secrets.TEST_SECRET_1 }}" + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # This is a required field for CodeGuru + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: CodeGuru Reviewer + uses: aws-actions/codeguru-reviewer@v1.1 + with: + s3_bucket: codeguru-reviewer-ming-bucket # S3 Bucket with "codeguru-reviewer-*" prefix + - name: Upload review result + if: ${{ github.event_name == 'push' }} + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: codeguru-results.sarif.json + - run: | + ls \ No newline at end of file diff --git a/src/main/java/com/journaldev/spring/controller/FileUploadController.java b/src/main/java/com/journaldev/spring/controller/FileUploadController.java index ec71bf3..06976d1 100644 --- a/src/main/java/com/journaldev/spring/controller/FileUploadController.java +++ b/src/main/java/com/journaldev/spring/controller/FileUploadController.java @@ -99,8 +99,11 @@ String uploadMultipleFileHandler(@RequestParam("name") String[] names, // Creating the directory to store file String rootPath = System.getProperty("catalina.home"); File dir = new File(rootPath + File.separator + "tmpFiles"); - if (!dir.exists()) - dir.mkdirs(); + if (!dir.exists()) { + if (!dir.mkdirs()) { + throw new RuntimeException("Failed to create " +rootPath + File.separator + "tmpFiles dir."); + } + } // Create the file on server File serverFile = new File(dir.getAbsolutePath() diff --git a/src/main/java/com/journaldev/spring/controller/PDFhighlightDemo.java b/src/main/java/com/journaldev/spring/controller/PDFhighlightDemo.java index 1d1bf16..28c4e24 100644 --- a/src/main/java/com/journaldev/spring/controller/PDFhighlightDemo.java +++ b/src/main/java/com/journaldev/spring/controller/PDFhighlightDemo.java @@ -23,10 +23,11 @@ public PDFhighlightDemo() throws IOException { public static void main(String[] args) throws IOException { - String rootPath = System.getProperty("catalina.home"); - File dir = new File(rootPath + File.separator + "tmpFiles"); - if (!dir.exists()) - dir.mkdirs(); +// String rootPath = System.getProperty("catalina.home"); +// File dir = new File(rootPath + File.separator + "tmpFiles"); +// if (!dir.exists()) +// dir.mkdirs(); +// PDDocument document = null; String fileName = "/Users/mqzhu/apache-tomcat-9.0.69/tmpFiles/saturdayprelimsdeepprogram_032348.pdf"; diff --git a/target/classes/com/journaldev/spring/controller/FileUploadController.class b/target/classes/com/journaldev/spring/controller/FileUploadController.class index a77e10e..443f3d2 100644 Binary files a/target/classes/com/journaldev/spring/controller/FileUploadController.class and b/target/classes/com/journaldev/spring/controller/FileUploadController.class differ diff --git a/target/classes/com/journaldev/spring/controller/PDFhighlightDemo.class b/target/classes/com/journaldev/spring/controller/PDFhighlightDemo.class index 6bf34c8..a9203e7 100644 Binary files a/target/classes/com/journaldev/spring/controller/PDFhighlightDemo.class and b/target/classes/com/journaldev/spring/controller/PDFhighlightDemo.class differ