File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -161,9 +161,19 @@ func escapeQuotes(s string) string {
161
161
162
162
func createMultipartHeader (param , fileName , contentType string ) textproto.MIMEHeader {
163
163
hdr := make (textproto.MIMEHeader )
164
- hdr .Set ("Content-Disposition" , fmt .Sprintf (`form-data; name="%s"; filename="%s"` ,
165
- escapeQuotes (param ), escapeQuotes (fileName )))
166
- hdr .Set ("Content-Type" , contentType )
164
+
165
+ var contentDispositionValue string
166
+ if IsStringEmpty (fileName ) {
167
+ contentDispositionValue = fmt .Sprintf (`form-data; name="%s"` , param )
168
+ } else {
169
+ contentDispositionValue = fmt .Sprintf (`form-data; name="%s"; filename="%s"` ,
170
+ param , escapeQuotes (fileName ))
171
+ }
172
+ hdr .Set ("Content-Disposition" , contentDispositionValue )
173
+
174
+ if ! IsStringEmpty (contentType ) {
175
+ hdr .Set (hdrContentTypeKey , contentType )
176
+ }
167
177
return hdr
168
178
}
169
179
You can’t perform that action at this time.
0 commit comments