[PL-24913]: Handle the error raised while creating a multipart input (#181)
parent
5a5c5ca5c5
commit
766414330d
@ -0,0 +1,26 @@
|
||||
package stash
|
||||
|
||||
import "mime/multipart"
|
||||
|
||||
type MultipartWriter struct {
|
||||
Writer *multipart.Writer
|
||||
Error error
|
||||
}
|
||||
|
||||
func (mw *MultipartWriter) Write(f, v string) {
|
||||
if mw.Error != nil {
|
||||
return
|
||||
}
|
||||
if v == "" {
|
||||
return
|
||||
}
|
||||
mw.Error = mw.Writer.WriteField(f, v)
|
||||
}
|
||||
|
||||
func (mw *MultipartWriter) Close() {
|
||||
mw.Writer.Close()
|
||||
}
|
||||
|
||||
func (mw *MultipartWriter) FormDataContentType() string {
|
||||
return mw.Writer.FormDataContentType()
|
||||
}
|
Loading…
Reference in New Issue