Added tracking for uploading and downloading files
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"fitra-backend/utils"
|
||||
)
|
||||
|
||||
func HandleFileDownload(c *gin.Context) {
|
||||
@@ -23,6 +24,9 @@ func HandleFileDownload(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Send analytics event
|
||||
utils.SendAnalyticsEvent("file_download", "/api/download/"+fileID+"/"+filename, "File Download", c.GetHeader("User-Agent"), c.ClientIP())
|
||||
|
||||
c.Header("Content-Description", "File Transfer")
|
||||
c.Header("Content-Transfer-Encoding", "binary")
|
||||
c.Header("Content-Disposition", "attachment; filename="+filename)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"fitra-backend/utils"
|
||||
)
|
||||
|
||||
func generateID() (string, error) {
|
||||
@@ -99,6 +100,9 @@ func HandleFileUpload(c *gin.Context) {
|
||||
baseURL = "http://localhost:8080"
|
||||
}
|
||||
|
||||
// Send analytics event
|
||||
utils.SendAnalyticsEvent("file_upload", "/api/upload", "File Upload", c.GetHeader("User-Agent"), c.ClientIP())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "File uploaded successfully",
|
||||
"id": fileID,
|
||||
|
||||
Reference in New Issue
Block a user