{"record":{"id":"e446b8ab371188a2","repo":"AlistGo/alist","slug":"path-path-is-a-directory","errorCode":null,"errorMessage":"Path: '{path}' is a directory","messagePattern":"Path: '(.+?)' is a directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gowebdav/cmd/gowebdav/main.go","lineNumber":249,"sourceCode":"\t}\n\tdefer f.Close()\n\n\t_, err = f.Write(bytes)\n\treturn err\n}\n\nfunc getStream(pathOrString string) (io.ReadCloser, error) {\n\n\tfi, err := os.Stat(pathOrString)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif fi.IsDir() {\n\t\treturn nil, &os.PathError{\n\t\t\tOp:   \"Open\",\n\t\t\tPath: pathOrString,\n\t\t\tErr:  errors.New(\"Path: '\" + pathOrString + \"' is a directory\"),\n\t\t}\n\t}\n\n\tf, err := os.Open(pathOrString)\n\tif err == nil {\n\t\treturn f, nil\n\t}\n\n\treturn nil, &os.PathError{\n\t\tOp:   \"Open\",\n\t\tPath: pathOrString,\n\t\tErr:  err,\n\t}\n}\n","sourceCodeStart":231,"sourceCodeEnd":264,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/pkg/gowebdav/cmd/gowebdav/main.go#L231-L264","documentation":"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.","triggerScenarios":"Invoking `gowebdav PUT /some/local/dir remote/path` where the second-to-last argument is an existing directory rather than a regular file.","commonSituations":"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.","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"],"exampleFix":"# before\n$ gowebdav PUT ./photos https://dav.example.com/photos\n\n# after\n$ find ./photos -type f -exec gowebdav PUT {} /photos/{} \\;","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(localPath)\nif err != nil { return err }\nif fi.IsDir() {\n\treturn fmt.Errorf(\"%s is a directory; PUT takes a single file\", localPath)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stat the local argument before invoking PUT","For folders, iterate files and PUT each one"],"tags":["gowebdav","cli","filesystem","upload"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}