Open NeoZephyr opened 2 years ago
file, header, err := req.FormFile("file") defer file.Close() content, err := ioutil.ReadAll(file) filename := header.Filename
buf := new(bytes.Buffer) bodyWriter := multipart.NewWriter(buf) fileWriter, err := bodyWriter.CreateFormFile("file", fileName) io.Copy(fileWriter, bytes.NewReader(data)) bodyWriter.Close() req.Header.Set("Content-Type", bodyWriter.FormDataContentType())