Fix file permissions, still
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:
@@ -71,6 +71,14 @@ 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"})
|
||||||
|
|||||||
@@ -17,5 +17,8 @@ else
|
|||||||
envsubst '${DOMAIN}' </etc/nginx/nginx_setup.conf.template >/etc/nginx/nginx.conf
|
envsubst '${DOMAIN}' </etc/nginx/nginx_setup.conf.template >/etc/nginx/nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure upload directory is traversable by nginx worker
|
||||||
|
chmod 755 /uploads 2>/dev/null || true
|
||||||
|
|
||||||
# Start nginx
|
# Start nginx
|
||||||
nginx -g 'daemon off;'
|
nginx -g 'daemon off;'
|
||||||
|
|||||||
Reference in New Issue
Block a user