'How to add content type field for every part of multipart form data in golang?

Need to add Content-Type for a file upload seperately, currently it is going as application/octet-stream but need to send application/json instead.

slice of the code, but don't know if its required.

    body := &bytes.Buffer{}
    writer := multipart.NewWriter(body)
    part, err := writer.CreateFormFile(paramName, filepath.Base(path))

need to change the content type for file that's being uploaded.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source