(file *FileUpload, contentType string)
| 27 | ) |
| 28 | |
| 29 | func createMultipartHeader(file *FileUpload, contentType string) textproto.MIMEHeader { |
| 30 | hdr := make(textproto.MIMEHeader) |
| 31 | |
| 32 | contentDispositionValue := "form-data" |
| 33 | cd := new(ContentDisposition) |
| 34 | if file.ParamName != "" { |
| 35 | cd.Add("name", file.ParamName) |
| 36 | } |
| 37 | if file.FileName != "" { |
| 38 | cd.Add("filename", file.FileName) |
| 39 | } |
| 40 | if file.ExtraContentDisposition != nil { |
| 41 | for _, kv := range file.ExtraContentDisposition.kv { |
| 42 | cd.Add(kv.Key, kv.Value) |
| 43 | } |
| 44 | } |
| 45 | if c := cd.string(); c != "" { |
| 46 | contentDispositionValue += c |
| 47 | } |
| 48 | hdr.Set("Content-Disposition", contentDispositionValue) |
| 49 | |
| 50 | if !util.IsStringEmpty(contentType) { |
| 51 | hdr.Set(header.ContentType, contentType) |
| 52 | } |
| 53 | return hdr |
| 54 | } |
| 55 | |
| 56 | func closeq(v any) { |
| 57 | if c, ok := v.(io.Closer); ok { |
no test coverage detected
searching dependent graphs…