Skip to content

Commit 12f6b8e

Browse files
author
Caitlin Bales (MSFT)
committed
Add header option to multipart helper
1 parent cb87e9d commit 12f6b8e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/main/java/com/microsoft/graph/models/extensions/Multipart.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.math.BigInteger;
88
import java.security.SecureRandom;
99

10+
import com.microsoft.graph.options.HeaderOption;
11+
1012
/**
1113
* Helper for submitting multipart data
1214
*
@@ -29,12 +31,20 @@ public Multipart() {
2931

3032
/**
3133
* Get the multipart boundary for use in the request header
32-
* @return The multipart boundary
34+
* @return the multipart boundary
3335
*/
3436
public String boundary() {
3537
return boundary;
3638
}
3739

40+
/**
41+
* Get the Content-Type header to send the multipart request
42+
* @return the multipart header option
43+
*/
44+
public HeaderOption header() {
45+
return new HeaderOption("Content-Type", "multipart/form-data; boundary=\"" + boundary + "\"");
46+
}
47+
3848
/**
3949
* Add a string part to the multipart body
4050
* @param name The name of the part
@@ -76,7 +86,7 @@ public void addHtmlPart(String name, String content) throws IOException {
7686
}
7787

7888
/**
79-
* Add an image part to the multipart body
89+
* Add an image/jpeg part to the multipart body
8090
* @param name The name of the part
8191
* @param imageFile The image file
8292
* @throws IOException Throws an exception if the output stream cannot be written to

src/test/java/com/microsoft/graph/functional/OneNoteTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.microsoft.graph.requests.extensions.IOnenotePageCollectionPage;
66
import com.microsoft.graph.requests.extensions.IOnenoteSectionCollectionPage;
77
import com.microsoft.graph.requests.extensions.ISectionGroupCollectionPage;
8+
import com.microsoft.graph.serializer.AdditionalDataManager;
89
import com.microsoft.graph.requests.extensions.IOnenoteRequestBuilder;
910
import com.microsoft.graph.models.extensions.Multipart;
1011
import com.microsoft.graph.models.extensions.Notebook;
@@ -408,9 +409,7 @@ public void testMultipartPost(){
408409

409410
// Add multipart request header
410411
List<Option> options = new ArrayList<Option>();
411-
options.add(new HeaderOption(
412-
"Content-Type", "multipart/form-data; boundary=\"" + multipart.boundary() + "\""
413-
));
412+
options.add(multipart.header());
414413

415414
// Post the multipart content
416415
OnenotePage page = orb

0 commit comments

Comments
 (0)