diff --git a/services/filesstore/s3store.go b/services/filesstore/s3store.go index 0868da5859..f0348bda65 100644 --- a/services/filesstore/s3store.go +++ b/services/filesstore/s3store.go @@ -350,7 +350,13 @@ func (b *S3FileBackend) ListDirectory(path string) (*[]string, *model.AppError) if object.Err != nil { return nil, model.NewAppError("ListDirectory", "utils.file.list_directory.s3.app_error", nil, object.Err.Error(), http.StatusInternalServerError) } - paths = append(paths, strings.Trim(object.Key, "/")) + // We strip the path prefix that gets applied, + // so that it remains transparent to the application. + object.Key = strings.TrimPrefix(object.Key, b.pathPrefix) + trimmed := strings.Trim(object.Key, "/") + if trimmed != "" { + paths = append(paths, trimmed) + } } return &paths, nil