Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AWS_SECRET_ACCESS_KEY | AWS `secret key` for API access. |
AWS_API_ENDPOINT | The endpoint for AWS API for local development. | | -
INDEX_DOCUMENT | Name of your index document. | | index.html
DIRECTORY_LISTINGS | List files when a specified URL ends with /. | | false
DIRECTORY_LISTINGS_FORMAT | Configures directory listing to be `html` (spider parsable) | | -
DIRECTORY_LISTINGS_FORMAT | Configures directory listing to be `html` (spider parsable) or `shtml` (pip compatible) | | -
HTTP_CACHE_CONTROL | Overrides S3's HTTP `Cache-Control` header. | | S3 Object metadata
HTTP_EXPIRES | Overrides S3's HTTP `Expires` header. | | S3 Object metadata
BASIC_AUTH_USER | User for basic authentication. | | -
Expand Down
15 changes: 15 additions & 0 deletions internal/controllers/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ func s3listFiles(w http.ResponseWriter, r *http.Request, client service.AWS, buc
fmt.Fprintln(w, toHTML(files, updatedAt))
return
}
if strings.EqualFold(config.Config.DirListingFormat, "shtml") {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, toSimpleHTML(files))
return
}

// Output as a JSON
bytes, merr := json.Marshal(files)
if merr != nil {
Expand Down Expand Up @@ -210,3 +216,12 @@ func toHTML(files []string, updatedAt map[string]time.Time) string {
}
return html + "</ul></body></html>"
}

func toSimpleHTML(files []string) string {

html := "<!DOCTYPE html><html><body>"
for _, file := range files {
html += "<a href=\"" + file + "\">" + file + "</a><br>"
}
return html + "</body></html>"
}