Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new upload options that were introduced recently #1342

Merged
merged 1 commit into from
May 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class ScreenRecordingUploadOptions {
private String user;
private String pass;
private String method;
private String fileFieldName;
private Map<String, String> headers;
private Map<String, Object> formFields;

public static ScreenRecordingUploadOptions uploadOptions() {
return new ScreenRecordingUploadOptions();
Expand Down Expand Up @@ -74,6 +77,45 @@ public ScreenRecordingUploadOptions withHttpMethod(RequestMethod method) {
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<String, Object> 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<String, String> headers) {
this.headers = checkNotNull(headers);
return this;
}

/**
* Builds a map, which is ready to be passed to the subordinated
* Appium API.
Expand All @@ -86,6 +128,9 @@ public Map<String, Object> build() {
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();
}
}