Fix file permissions
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled

This commit is contained in:
2026-03-09 16:20:47 +00:00
parent 8e50537333
commit 99ddd7d494
2 changed files with 10 additions and 29 deletions

View File

@@ -66,26 +66,11 @@ func (store *Store) UploadMessageFile(ctx *gin.Context) {
}
filename := hex.EncodeToString(b) + ext
uploadDir := "/backend/uploads"
if err := os.MkdirAll(uploadDir, 0755); err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create upload directory"})
return
}
// Ensure directory is world-readable so nginx can serve files
if err := os.Chmod(uploadDir, 0755); err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create upload directory"})
return
}
dest := filepath.Join(uploadDir, filename)
if err := ctx.SaveUploadedFile(file, dest); err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save file"})
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})
}