dropbox-sdk-go-unofficial icon indicating copy to clipboard operation
dropbox-sdk-go-unofficial copied to clipboard

Can't get .tag: "file" or .tag: "folder" when get list folders API

Open phuongTP1998 opened this issue 4 years ago • 2 comments

I try to get the ".tag" field to identify between files and folders but I don't figure out how to get it from the the sdk This is how I pass the ListFolderArg

image but the result doesn't appear the ".tag" field

image Hope someone can help! Thanks

phuongTP1998 avatar Jan 26 '21 13:01 phuongTP1998

From the document: image

phuongTP1998 avatar Jan 26 '21 13:01 phuongTP1998

Here is a way how you can identify between files and folders:

	path := "/my/path"
	args := files.NewListFolderArg(path)
	args.Recursive = true
	res, err := dbx.ListFolder(args)
	if err != nil {
		panic(err)
	}

	for k, v := range res.Entries {
		fmt.Printf("%+v // %+v\n", k, v)

		switch v.(type) {
		case *files.FileMetadata:
			fmt.Println("File")
		case *files.FolderMetadata:
			fmt.Println("Folder")
		}

	}

andygrunwald avatar Feb 12 '23 19:02 andygrunwald