@@ -23,7 +23,7 @@ import (
2323)
2424
2525// DoMultiPartRequest creates and executes a multipart/form-data HTTP request for file uploads and form fields.
26- func (c * Client ) DoMultiPartRequest (method , endpoint string , files map [string ]string , params map [string ]string , contentTypes map [string ]string , headersMap map [string ]http.Header , out interface {}) (* http.Response , error ) {
26+ func (c * Client ) DoMultiPartRequest (method , endpoint string , files map [string ][] string , params map [string ]string , contentTypes map [string ]string , headersMap map [string ]http.Header , out interface {}) (* http.Response , error ) {
2727 log := c .Logger
2828 ctx , cancel := context .WithCancel (context .Background ())
2929 defer cancel () // Ensure the context is canceled when the function returns
@@ -107,13 +107,15 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string]st
107107}
108108
109109// createMultipartRequestBody creates a multipart request body with the provided files and form fields, supporting custom content types and headers.
110- func createMultipartRequestBody (files map [string ]string , params map [string ]string , contentTypes map [string ]string , headersMap map [string ]http.Header , log logger.Logger ) (* bytes.Buffer , string , error ) {
110+ func createMultipartRequestBody (files map [string ][] string , params map [string ]string , contentTypes map [string ]string , headersMap map [string ]http.Header , log logger.Logger ) (* bytes.Buffer , string , error ) {
111111 body := & bytes.Buffer {}
112112 writer := multipart .NewWriter (body )
113113
114- for fieldName , filePath := range files {
115- if err := addFilePart (writer , fieldName , filePath , contentTypes , headersMap , log ); err != nil {
116- return nil , "" , err
114+ for fieldName , filePaths := range files {
115+ for _ , filePath := range filePaths {
116+ if err := addFilePart (writer , fieldName , filePath , contentTypes , headersMap , log ); err != nil {
117+ return nil , "" , err
118+ }
117119 }
118120 }
119121
0 commit comments