@@ -27,8 +27,9 @@ export class MultipartBody implements Parsable {
27
27
* @param partContentType the content type of the part to add or replace.
28
28
* @param content the content of the part to add or replace.
29
29
* @param serializationCallback the serialization callback to use when serializing the part.
30
+ * @param fileName the name of the file associated with this part.
30
31
*/
31
- public addOrReplacePart < T > ( partName : string , partContentType : string , content : T , serializationCallback ?: ModelSerializerFunction < Parsable > ) : void {
32
+ public addOrReplacePart < T > ( partName : string , partContentType : string , content : T , serializationCallback ?: ModelSerializerFunction < Parsable > , fileName ?: string ) : void {
32
33
if ( ! partName ) throw new Error ( "partName cannot be undefined" ) ;
33
34
if ( ! partContentType ) {
34
35
throw new Error ( "partContentType cannot be undefined" ) ;
@@ -39,6 +40,7 @@ export class MultipartBody implements Parsable {
39
40
contentType : partContentType ,
40
41
content,
41
42
originalName : partName ,
43
+ fileName,
42
44
serializationCallback,
43
45
} ;
44
46
}
@@ -90,6 +92,7 @@ interface MultipartEntry {
90
92
contentType : string ;
91
93
content : any ;
92
94
originalName : string ;
95
+ fileName ?: string ;
93
96
serializationCallback ?: ModelSerializerFunction < Parsable > ;
94
97
}
95
98
@@ -124,7 +127,7 @@ export const serializeMultipartBody = (writer: SerializationWriter, multipartBod
124
127
const part = parts [ partName ] ;
125
128
writer . writeStringValue ( "Content-Type" , part . contentType ) ;
126
129
writer . writeStringValue ( undefined , "\r\n" ) ;
127
- writer . writeStringValue ( "Content-Disposition" , ' form-data; name="' + part . originalName + '"' ) ;
130
+ writer . writeStringValue ( "Content-Disposition" , ` form-data; name="${ part . originalName } " ${ part . fileName ? `; filename=" ${ part . fileName } "` : "" } ` ) ;
128
131
writer . writeStringValue ( undefined , "\r\n" ) ;
129
132
writer . writeStringValue ( undefined , "\r\n" ) ;
130
133
if ( typeof part . content === "string" ) {
0 commit comments