From a0bc4382618b893d3a676f7ac0ce8afc499c01e5 Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Wed, 16 Nov 2022 18:05:17 -0500 Subject: [PATCH] Add mime.type for yaml According to https://www.ietf.org/archive/id/draft-ietf-httpapi-yaml-mediatypes-00.html, we should be using `application/yaml`, but since GCS uses application/x-yaml, and we emulate GCS, we stick to what GCS' behavior. Closes #990. --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index 0150731d89..db69daa907 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,7 @@ func main() { var emptyBuckets []string opts := cfg.ToFakeGcsOptions() if cfg.Seed != "" { + addMimeTypes() opts.InitialObjects, emptyBuckets = generateObjectsFromFiles(logger, cfg.Seed) } @@ -50,6 +51,16 @@ func main() { <-ch } +func addMimeTypes() { + mapping := map[string]string{ + ".yaml": "application/x-yaml", + ".yml": "application/x-yaml", + } + for ext, typ := range mapping { + mime.AddExtensionType(ext, typ) + } +} + func generateObjectsFromFiles(logger *logrus.Logger, folder string) ([]fakestorage.Object, []string) { var objects []fakestorage.Object var emptyBuckets []string