Skip to content

Commit

Permalink
make metadata work
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmenPopoviciu committed Aug 23, 2024
1 parent 4f7acde commit eed70a0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
57 changes: 57 additions & 0 deletions fixtures/workers-with-assets/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Workers with Assets

Welcome to Workers + Assets YAY!

Please proceed with much excitement ^.^

.................
.......-++**********:.
..-+****++**********#:
...-+***+++====+********##=
....:=****+======+***********##+
....-****+======+*************###+
.:==+*+======+***************####=
....-===--=====++****************#####:
....:====-:::-==+******************#####+.
..-====:::::::+*******************#####*..
..-===-:::::::-==+*****************######=..
..-===-::::::-=======***************######*.
...-===-::::::-==========+************######*:.
...-===-::::::-==----========+*********#######:..
.-===-::::::--::::::::::-======+******#######-. .
..:====::::::-=:::-*####*-:::-=======+**#######-.
.:====-:::::-==:::*#########-::========+**#####-
..====-:::::-===-::###########*:::======*******+..
..=+====:::::=====::-############:::====+*******=...
....:=++====:::-======-::###########*:::===+*******-..
...........:-==+**+=++++=============-:::*#########-::===********:..
....--=+************====+++===============:::=*####*=:::-=+*******=..
.:*************###*=====++++================::::::::::-==********:..
..*****#############=======++++==========================+*******+...
...+****#############*==:::-===++++========================********-.
...+****###############+=::::=====+++++====================********+...
.=****################*=-:::-======+++++=================+********:..
..-****##################===:-=========++++++=============+********:..
.+***####################===========+***#++++++=========+********=..
.*###################+-.-=======+****##*==+++++++====+********=...
...-+#############*=...-++=====+****####+=====++++++*********+...
....-*######+:.....++++===******####==========+*######**+..
...+=.....:::-+++++******#####=========+***######*..
.......::::::=++******#####+========***********:...
....::::::...+*****######=======+**********##*.
..:::::....-*****######+=====+**********#####*.
...:::::...:******#####*+++++*********#########+.
..:::::...+*****######+++++++=.=###############:.
.:::::..-*****######-..-=++=..-##########***###..
....::::..=****######=....::::..:########******##*..
...::::..+***######-.....::::...*##***********###=..
..::::...-**####*:......::::...###************###-..
..:::......=##*:......:::::...+##*************###:
...::::...............:::::....+##*************####.
...::::::::::::::..:::::::......**************###-..
.::::::::::::::::::::::..... ...:***********###+....
..::::.......::::::...... ..:********###*:...
........ ...=******###=..
.=***###+..
..*####:...
........
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions fixtures/workers-with-assets/public/yay.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

.----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. |
| | ____ ____ | || | __ | || | ____ ____ | |
| | |_ _||_ _| | || | / \ | || | |_ _||_ _| | |
| | \ \ / / | || | / /\ \ | || | \ \ / / | |
| | \ \/ / | || | / ____ \ | || | \ \/ / | |
| | _| |_ | || | _/ / \ \_ | || | _| |_ | |
| | |______| | || ||____| |____|| || | |______| | |
| | | || | | || | | |
| '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------'
11 changes: 10 additions & 1 deletion packages/miniflare/src/workers/kv/assets.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export default <ExportedHandler<Env>>{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { filePath, contentType } = entry;
const blobsService = env[SharedBindings.MAYBE_SERVICE_BLOBS];
return blobsService.fetch(new URL(filePath, "http://placeholder"));
const response = await blobsService.fetch(
new URL(filePath, "http://placeholder")
);
const newResponse = new Response(response.body, response);
// ensure the runtime will return the metadata we need
newResponse.headers.append(
"cf-kv-metadata",
`{"contentType": "${contentType}"}`
);
return newResponse;
},
};

0 comments on commit eed70a0

Please sign in to comment.