Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is multipart/form-data supported #418

Open
fabianpage opened this issue Nov 27, 2019 · 3 comments
Open

Is multipart/form-data supported #418

fabianpage opened this issue Nov 27, 2019 · 3 comments

Comments

@fabianpage
Copy link
Contributor

An endpoint which is used to upload files needs the multipart/form-data format. Is that supported by endpoints?

@julienrf
Copy link
Member

Yes and no: currently, it’s not implemented, but it is easy to add without doing any change to the library.

  • Create a Multiparts trait with a RequestEntity[Multipart] constructor:
    import endpoints.algebra
    trait Multiparts extends algebra.Endpoints {
      type Multipart
      def multipartRequest: RequestEntity[Multipart]
    }
  • Create a server interpreter:
    import endpoints.akkahttp.server
    trait MultipartsServer extends Multiparts with server.Endpoints {
      type Multipart = akka.http.scaladsl.model.Multipart // (or maybe something different)
      def multipartRequest = ... // you will have to find out what to put here!
    }
  • Create other interpreters as needed
  • Use it!
    trait SomeEndpoints extends algebra.Endpoints with Multiparts {
      val foo = endpoint(post(path / "upload", multipartRequest), ok(emptyResponse))
    }
  • Make a PR to add it here!

I can help you if you are stuck ;) multipart/form-data is definitely something we need to support in the core!

@julienrf
Copy link
Member

Hey @fabianpage, have you found a satisfactory solution?

@Kazark
Copy link

Kazark commented Feb 18, 2022

I need this for http4s. Will see what I can do based on your comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants