From dea6bb18422d591bf47e7538bd622a56b188f02b Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Sun, 10 May 2020 09:20:00 +0200 Subject: [PATCH] feat: Add new upload options that were introduced recently (#1342) --- .../ScreenRecordingUploadOptions.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/io/appium/java_client/screenrecording/ScreenRecordingUploadOptions.java b/src/main/java/io/appium/java_client/screenrecording/ScreenRecordingUploadOptions.java index dcad861b..424bfedd 100644 --- a/src/main/java/io/appium/java_client/screenrecording/ScreenRecordingUploadOptions.java +++ b/src/main/java/io/appium/java_client/screenrecording/ScreenRecordingUploadOptions.java @@ -28,6 +28,9 @@ public class ScreenRecordingUploadOptions { private String user; private String pass; private String method; + private String fileFieldName; + private Map headers; + private Map formFields; public static ScreenRecordingUploadOptions uploadOptions() { return new ScreenRecordingUploadOptions(); @@ -74,6 +77,45 @@ public class ScreenRecordingUploadOptions { return this; } + /** + * Sets the form field name containing the binary payload in multipart/form-data + * requests. + * + * @since Appium 1.18.0 + * @param fileFieldName The name of the form field containing the binary payload. + * "file" by default. + * @return self instance for chaining. + */ + public ScreenRecordingUploadOptions withFileFieldName(String fileFieldName) { + this.fileFieldName = checkNotNull(fileFieldName); + return this; + } + + /** + * Sets additional form fields in multipart/form-data requests. + * + * @since Appium 1.18.0 + * @param formFields form fields mapping. If any entry has the same key as + * `fileFieldName` then it is going to be ignored. + * @return self instance for chaining. + */ + public ScreenRecordingUploadOptions withFormFields(Map formFields) { + this.formFields = checkNotNull(formFields); + return this; + } + + /** + * Sets additional headers in multipart/form-data requests. + * + * @since Appium 1.18.0 + * @param headers headers mapping. + * @return self instance for chaining. + */ + public ScreenRecordingUploadOptions withHeaders(Map headers) { + this.headers = checkNotNull(headers); + return this; + } + /** * Builds a map, which is ready to be passed to the subordinated * Appium API. @@ -86,6 +128,9 @@ public class ScreenRecordingUploadOptions { ofNullable(user).map(x -> builder.put("user", x)); ofNullable(pass).map(x -> builder.put("pass", x)); ofNullable(method).map(x -> builder.put("method", x)); + ofNullable(fileFieldName).map(x -> builder.put("fileFieldName", x)); + ofNullable(formFields).map(x -> builder.put("formFields", x)); + ofNullable(headers).map(x -> builder.put("headers", x)); return builder.build(); } } -- GitLab