Add file viewer dispatch for handling multiple file types and extend download timeout

This commit is contained in:
Leon Bösche
2026-01-25 16:14:03 +01:00
parent d5aecdfba8
commit 9bc03f6db8
7 changed files with 222 additions and 81 deletions

View File

@@ -3080,8 +3080,12 @@ func publicFileDownloadHandler(w http.ResponseWriter, r *http.Request, db *datab
return
}
// Create context with longer timeout for file downloads
downloadCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
// Stream file
resp, err := client.Download(r.Context(), file.Path, "")
resp, err := client.Download(downloadCtx, file.Path, "")
if err != nil {
errors.LogError(r, err, "Failed to download file")
errors.WriteError(w, errors.CodeInternal, "Server error", http.StatusInternalServerError)
@@ -3189,7 +3193,7 @@ func publicFileViewHandler(w http.ResponseWriter, r *http.Request, db *database.
}
// Create context with longer timeout for file downloads
downloadCtx, cancel := context.WithTimeout(r.Context(), 5*time.Minute)
downloadCtx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
// Stream file

View File

@@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
)
// CreateNextcloudUser creates a new Nextcloud user account via OCS API
@@ -71,6 +72,6 @@ func NewUserWebDAVClient(nextcloudBaseURL, username, password string) *WebDAVCli
user: username,
pass: password,
basePrefix: "/",
httpClient: &http.Client{},
httpClient: &http.Client{Timeout: 10 * time.Minute},
}
}

View File

@@ -8,6 +8,7 @@ import (
"net/url"
"path"
"strings"
"time"
"go.b0esche.cloud/backend/internal/config"
)
@@ -37,7 +38,7 @@ func NewWebDAVClient(cfg *config.Config) *WebDAVClient {
user: cfg.NextcloudUser,
pass: cfg.NextcloudPass,
basePrefix: strings.TrimRight(base, "/"),
httpClient: &http.Client{},
httpClient: &http.Client{Timeout: 10 * time.Minute},
}
}