File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Sources/Request/Request/FormParam Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -54,11 +54,25 @@ internal extension FormParam {
54
54
}
55
55
56
56
func disposition< S> ( _ fileName: S , withType mediaType: MediaType ) -> Data where S: StringProtocol {
57
- let name = fileName. split ( separator: " . " ) . dropLast ( ) . joined ( separator: " . " )
57
+ let name : String
58
+ if fileName. contains ( " . " ) {
59
+ name = fileName
60
+ . split ( separator: " . " )
61
+ . dropLast ( )
62
+ . joined ( separator: " . " )
63
+ } else {
64
+ name = " \( fileName) "
65
+ }
58
66
59
67
var contents = Data ( )
60
- contents. append ( Data ( " Content-Disposition: form-data; name= \" \( name) \" ; filename= \" \( fileName) \" \( breakLine) " . utf8) )
61
- contents. append ( Data ( " Content-Type: \( mediaType) \( breakLine) " . utf8) )
68
+
69
+ contents. append ( Data ( " Content-Disposition: form-data; name= \" \( name) \" ; " . utf8) )
70
+ contents. append ( Data ( " filename= \" \( fileName) \" " . utf8) )
71
+ contents. append ( Data ( breakLine. utf8) )
72
+
73
+ contents. append ( Data ( " Content-Type: \( mediaType) " . utf8) )
74
+ contents. append ( Data ( breakLine. utf8) )
75
+
62
76
return contents
63
77
}
64
78
You can’t perform that action at this time.
0 commit comments