Skip to content

Commit

Permalink
docs: explain multipart for cloudflare workers (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy authored May 29, 2024
1 parent 62ace9d commit 2662dcd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/json-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Thus, any third-party consumer should utilize the body entity named `payload_jso
Due to this structure, trying to parse the full `multipart/form-data` as JSON will not succeed until you specifically grab the `payload_json` entity. Competent web frameworks should handle the multipart parsing, so you can easily access the relevant form values.

See [here](https://gitea.ivr.fi/Leppunen/runelite-dink-api/src/branch/master/handlers/dinkHandler.js) for an example project that leverages [`@fastify/multipart`](https://github.com/fastify/fastify-multipart) to read the JSON payload and screenshot file.
For Cloudflare Workers, utilize the [`request.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method.
For Express, utilize the [`Multer`](https://github.com/expressjs/multer) middleware.
For Golang, utilize the [`ParseMultipartForm`](https://pkg.go.dev/net/http#Request.ParseMultipartForm) function.
For http4k, utilize the [`http4k-multipart`](https://www.http4k.org/guide/howto/use_multipart_forms/#lens_typesafe_validating_api_-_reads_all_contents_onto_diskmemory) module.
Expand Down

0 comments on commit 2662dcd

Please sign in to comment.