From af5b846caddca040827f03649b5ea7134ae7dbb3 Mon Sep 17 00:00:00 2001 From: Sungho Choi Date: Wed, 17 May 2023 22:02:07 +0900 Subject: [PATCH] Support for parsing json in ObjectNames() --- swift.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/swift.go b/swift.go index c9357ee3f..b4c5602b7 100644 --- a/swift.go +++ b/swift.go @@ -1066,7 +1066,20 @@ func (c *Connection) ObjectNames(ctx context.Context, container string, opts *Ob if err != nil { return nil, err } - return readLines(resp) + switch resp.Header.Get("Content-Type") { + case "application/json": + var objects []Object + err := readJson(resp, &objects) + + var names []string + for _, obj := range objects { + names = append(names, obj.Name) + } + + return names, err + default: + return readLines(resp) + } } // Object contains information about an object