package clients

import (
	"io"
	"mime/multipart"
)

// 将 reader 写入到 multipart writer 的指定字段中
func writeFileFromReader(mw *multipart.Writer, field, name string, r io.Reader) error {
	w, err := mw.CreateFormFile(field, name)
	if err != nil {
		return err
	}
	_, err = io.Copy(w, r)
	return err
}
