1 Distinguish between folders and common files, folders are listed first

2 Add some custom headers that need to be exposed
This commit is contained in:
henry 2020-12-31 00:03:22 +08:00
parent 7458ff9523
commit 14ddd15508
2 changed files with 21 additions and 1 deletions

View file

@ -38,7 +38,17 @@ func (f *Filer) ListDirectoryEntries(ctx context.Context, p util.FullPath, start
}
}
return entries, err
//Distinguish between folders and common files, folders are listed first
var folderEntries, commonEntries []*Entry
for i, _ := range entries {
if entries[i].IsDirectory() {
folderEntries = append(folderEntries, entries[i])
} else {
commonEntries = append(commonEntries, entries[i])
}
}
folderEntries = append(folderEntries, commonEntries...)
return folderEntries, err
}
func (f *Filer) doListPatternMatchedEntries(ctx context.Context, p util.FullPath, startFileName string, inclusive bool, limit int, prefix, restNamePattern string) (matchedEntries []*Entry, missedCount int, lastFileName string, err error) {

View file

@ -100,6 +100,16 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
w.Header().Set(k, string(v))
}
//Add some custom headers that need to be exposed
seaweedHeaders := []string{}
for i, _ := range w.Header() {
if strings.Contains(i, "Seaweed") {
seaweedHeaders = append(seaweedHeaders, i)
}
}
seaweedHeaders = append(seaweedHeaders, "Content-Disposition")
w.Header().Set("Access-Control-Expose-Headers", strings.Join(seaweedHeaders, ","))
//set tag count
if r.Method == "GET" {
tagCount := 0