AlistGo/alist · error
Path: '{path}' is a directory
Error message
Path: '{path}' is a directory What it means
Returned by getStream() in the gowebdav CLI when the local path passed to PUT points at a directory. The function stats the argument to open a file stream for upload; a directory cannot be streamed as a single body, so it fails with an os.PathError wrapping this message.
Source
Thrown at pkg/gowebdav/cmd/gowebdav/main.go:249
}
defer f.Close()
_, err = f.Write(bytes)
return err
}
func getStream(pathOrString string) (io.ReadCloser, error) {
fi, err := os.Stat(pathOrString)
if err != nil {
return nil, err
}
if fi.IsDir() {
return nil, &os.PathError{
Op: "Open",
Path: pathOrString,
Err: errors.New("Path: '" + pathOrString + "' is a directory"),
}
}
f, err := os.Open(pathOrString)
if err == nil {
return f, nil
}
return nil, &os.PathError{
Op: "Open",
Path: pathOrString,
Err: err,
}
}
View on GitHub (pinned to 843d9dc814)
Solutions
- Point the PUT argument at a regular file, not a directory
- To upload a whole directory, loop over its files in shell and PUT each one individually
- Create the remote directory first with MKDIR when mirroring structure
Example fix
# before
$ gowebdav PUT ./photos https://dav.example.com/photos
# after
$ find ./photos -type f -exec gowebdav PUT {} /photos/{} \; Defensive patterns
Strategy: validation
Validate before calling
fi, err := os.Stat(localPath)
if err != nil { return err }
if fi.IsDir() {
return fmt.Errorf("%s is a directory; PUT takes a single file", localPath)
} Prevention
- Stat the local argument before invoking PUT
- For folders, iterate files and PUT each one
When it happens
Trigger: Invoking `gowebdav PUT /some/local/dir remote/path` where the second-to-last argument is an existing directory rather than a regular file.
Common situations: Trying to upload a folder instead of a file (WebDAV PUT uploads one file; there is no recursive PUT in this CLI), shell glob collapsing incorrectly, or forgetting to name the target file.
Related errors
- Unsupported method: {method}
- 123 offline download cannot target the root directory, pick
- file_id is required
- same-name dirs cannot be Put
- invalid hash
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/e446b8ab371188a2.
Report an issue: GitHub.