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: blogs api #489

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
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
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
Loading