The Wayback Machine - https://web.archive.org/web/20200521032739/https://github.com/gin-gonic/gin/issues/2136
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

No example for file upload with MIME as content type #2136

Open
KernelDeimos opened this issue Nov 16, 2019 · 1 comment
Open

No example for file upload with MIME as content type #2136

KernelDeimos opened this issue Nov 16, 2019 · 1 comment

Comments

@KernelDeimos
Copy link

@KernelDeimos KernelDeimos commented Nov 16, 2019

Description

Using the fetch API from WHATWG in Google Chrome, an image upload does not have Content-Type multipart/form-data. Instead, the content type is set to the MIME type (ex: image/jpeg) with a boundary parameter. Setting Content-Type explicitly to multipart/form-data should result in an error (and it does).

How to reproduce

Follow an existing image upload example from Gin's documentation, but use the fetch API on the client to send the upload request.

Expectations

Use for non-multipart requests should be documented, as people may try to use the fetch API with Gin.

Actual result

I still haven't figured out how to get it working. Probably gonna have to dive into how Gin works internally to figure this out.

Environment

  • go version: N/A
  • gin version (or commit ref): N/A
  • operating system: N/A
@KernelDeimos
Copy link
Author

@KernelDeimos KernelDeimos commented Nov 16, 2019

Turns out I didn't need to do anything more complicated than call c.GetRawData() to get the bytes of my uploaded file. It may be helpful to note this with a comment in the existing examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.