Fix formatting issues in Nextcloud user creation and WebDAV client methods
This commit is contained in:
@@ -17,7 +17,7 @@ func CreateNextcloudUser(nextcloudBaseURL, adminUser, adminPass, username, passw
|
||||
url := fmt.Sprintf("%s/ocs/v1.php/cloud/users", baseURL)
|
||||
|
||||
// OCS API expects form-encoded data, not JSON
|
||||
formData := fmt.Sprintf("userid=%s&password=%s",
|
||||
formData := fmt.Sprintf("userid=%s&password=%s",
|
||||
strings.ReplaceAll(username, " ", "+"),
|
||||
strings.ReplaceAll(password, " ", "+"))
|
||||
|
||||
@@ -63,7 +63,7 @@ func NewUserWebDAVClient(nextcloudBaseURL, username, password string) *WebDAVCli
|
||||
baseURL := strings.Split(nextcloudBaseURL, "/remote.php")[0]
|
||||
// Build the full WebDAV URL for this user
|
||||
fullURL := fmt.Sprintf("%s/remote.php/dav/files/%s", baseURL, username)
|
||||
|
||||
|
||||
fmt.Printf("[WEBDAV-USER] Input URL: %s, Base: %s, Full: %s, User: %s\n", nextcloudBaseURL, baseURL, fullURL, username)
|
||||
|
||||
return &WebDAVClient{
|
||||
|
||||
@@ -88,7 +88,7 @@ func (c *WebDAVClient) Upload(ctx context.Context, remotePath string, r io.Reade
|
||||
u = ""
|
||||
}
|
||||
u = strings.TrimRight(u, "/")
|
||||
|
||||
|
||||
var full string
|
||||
if u == "" {
|
||||
full = fmt.Sprintf("%s/%s", c.baseURL, url.PathEscape(rel))
|
||||
@@ -96,7 +96,7 @@ func (c *WebDAVClient) Upload(ctx context.Context, remotePath string, r io.Reade
|
||||
full = fmt.Sprintf("%s%s/%s", c.baseURL, u, url.PathEscape(rel))
|
||||
}
|
||||
full = strings.ReplaceAll(full, "%2F", "/")
|
||||
|
||||
|
||||
fmt.Printf("[WEBDAV-UPLOAD] BaseURL: %s, BasePrefix: %s, RemotePath: %s, Full URL: %s\n", c.baseURL, c.basePrefix, remotePath, full)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "PUT", full, r)
|
||||
@@ -135,7 +135,7 @@ func (c *WebDAVClient) Download(ctx context.Context, remotePath string) (io.Read
|
||||
u = ""
|
||||
}
|
||||
u = strings.TrimRight(u, "/")
|
||||
|
||||
|
||||
var full string
|
||||
if u == "" {
|
||||
full = fmt.Sprintf("%s/%s", c.baseURL, url.PathEscape(rel))
|
||||
@@ -178,7 +178,7 @@ func (c *WebDAVClient) Delete(ctx context.Context, remotePath string) error {
|
||||
u = ""
|
||||
}
|
||||
u = strings.TrimRight(u, "/")
|
||||
|
||||
|
||||
var full string
|
||||
if u == "" {
|
||||
full = fmt.Sprintf("%s/%s", c.baseURL, url.PathEscape(rel))
|
||||
|
||||
Reference in New Issue
Block a user