Skip to content

Commit

Permalink
Fix: blogs api
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sumi-k committed Sep 20, 2023
1 parent 018c11b commit bd48487
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-frontend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
repository_dispatch:
types: [deploy-blog-dev]
push:
branches:
- "master"

jobs:
deploy-frontend-dev:
Expand Down
4 changes: 2 additions & 2 deletions blogs/blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Blog struct {

func Get(c *gin.Context) {

fileName := "./blogs.json"
fileName := "/tmp/blogs.json"

// check if file is present or not
_, err := os.Stat(fileName)
Expand All @@ -51,7 +51,7 @@ func Get(c *gin.Context) {
}

//read file from AWS S3
utils.DownloadFileFromS3("./blogs.json", sess)
utils.DownloadFileFromS3(fileName, sess)
}

// get blogs from API
Expand Down
4 changes: 2 additions & 2 deletions utils/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func DownloadFileFromS3(fileName string, sess *session.Session) {
_, err = downloader.Download(file,
&s3.GetObjectInput{
Bucket: aws.String("canopas-blogs"),
Key: aws.String(fileName),
Key: aws.String("blogs.json"),
})

if err != nil {
Expand All @@ -84,7 +84,7 @@ func UploadFileToS3(fileName string, sess *session.Session) {

_, err = s3.New(sess).PutObject(&s3.PutObjectInput{
Bucket: aws.String("canopas-blogs"),
Key: aws.String("/" + fileName),
Key: aws.String("/blogs.json"),
ACL: aws.String("public-read"),
Body: bytes.NewReader(fileBuffer),
ContentLength: aws.Int64(fileSize),
Expand Down

0 comments on commit bd48487

Please sign in to comment.