Removed setting own permissions, let dockerfile entryhost do it
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -71,23 +70,11 @@ func (store *Store) UploadMessageFile(ctx *gin.Context) {
|
|||||||
filename := hex.EncodeToString(b) + ext
|
filename := hex.EncodeToString(b) + ext
|
||||||
|
|
||||||
uploadDir := "/backend/uploads/"
|
uploadDir := "/backend/uploads/"
|
||||||
if err := os.MkdirAll(uploadDir, 0755); err != nil {
|
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create upload directory"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := os.Chmod(uploadDir, 0755); err != nil {
|
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to set directory permissions"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dest := filepath.Join(uploadDir, filename)
|
dest := filepath.Join(uploadDir, filename)
|
||||||
if err := ctx.SaveUploadedFile(file, dest); err != nil {
|
if err := ctx.SaveUploadedFile(file, dest); err != nil {
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save file"})
|
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save file"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := os.Chmod(dest, 0644); err != nil {
|
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to set file permissions"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, gin.H{"url": "/uploads/" + filename})
|
ctx.JSON(http.StatusOK, gin.H{"url": "/uploads/" + filename})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user