Skip to content

Commit

Permalink
Merge pull request #1285 from bcgov/dev-rook-RQ-FOIMOD-3551
Browse files Browse the repository at this point in the history
set content type header for html file created
richard-aot authored Jan 28, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents d2a44ad + d518dc9 commit a6933cd
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions computingservices/OpenInfoServices/lib/awslib/s3.go
Original file line number Diff line number Diff line change
@@ -294,6 +294,28 @@ func SaveFileS3(openInfoBucket string, openInfoPrefix string, filename string, b
return err
}

func SaveHTMLS3(openInfoBucket string, openInfoPrefix string, filename string, buf []byte) error {
bucket := openInfoBucket //"dev-openinfopub"
prefix := openInfoPrefix //"poc/packages/HSG_2024_40515/" // Folder prefix in the bucket

svc := CreateS3Client()

// Upload the HTML content to S3
_, err := svc.PutObject(context.TODO(), &s3.PutObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(prefix + filename),
Body: bytes.NewReader(buf),
ContentType: aws.String("text/html"),
})
if err != nil {
fmt.Println("Error uploading file:", err)
} else {
fmt.Println("File uploaded successfully!")
}

return err
}

func SaveXMLS3(openInfoBucket string, openInfoPrefix string, filename string, buf []byte) error {
bucket := openInfoBucket //"dev-openinfopub"
prefix := openInfoPrefix //"poc/packages/HSG_2024_40515/" // Folder prefix in the bucket
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ func Publish(msg OpenInfoMessage, db *sql.DB) {
}

buf := files.CreateHTML(variables)
err = awslib.SaveFileS3(msg.BCgovcode+"-"+env+"-e", msg.Axisrequestid+"/openinfo/", msg.Axisrequestid+".html", buf.Bytes())
err = awslib.SaveHTMLS3(msg.BCgovcode+"-"+env+"-e", msg.Axisrequestid+"/openinfo/", msg.Axisrequestid+".html", buf.Bytes())
if err != nil {
log.Fatalf("%v", err)
return

0 comments on commit a6933cd

Please sign in to comment.