createUpload method

Future<CreateUploadResult> createUpload({
  1. required String name,
  2. required String projectArn,
  3. required UploadType type,
  4. String? contentType,
})

Uploads an app or test scripts.

May throw ArgumentException. May throw NotFoundException. May throw LimitExceededException. May throw ServiceAccountException.

Parameter name : The upload's file name. The name should not contain any forward slashes (/). If you are uploading an iOS app, the file name must end with the .ipa extension. If you are uploading an Android app, the file name must end with the .apk extension. For all others, the file name must end with the .zip file extension.

Parameter projectArn : The ARN of the project for the upload.

Parameter type : The upload's upload type.

Must be one of the following values:

  • ANDROID_APP
  • IOS_APP
  • WEB_APP
  • EXTERNAL_DATA
  • APPIUM_JAVA_JUNIT_TEST_PACKAGE
  • APPIUM_JAVA_TESTNG_TEST_PACKAGE
  • APPIUM_PYTHON_TEST_PACKAGE
  • APPIUM_NODE_TEST_PACKAGE
  • APPIUM_RUBY_TEST_PACKAGE
  • APPIUM_WEB_JAVA_JUNIT_TEST_PACKAGE
  • APPIUM_WEB_JAVA_TESTNG_TEST_PACKAGE
  • APPIUM_WEB_PYTHON_TEST_PACKAGE
  • APPIUM_WEB_NODE_TEST_PACKAGE
  • APPIUM_WEB_RUBY_TEST_PACKAGE
  • CALABASH_TEST_PACKAGE
  • INSTRUMENTATION_TEST_PACKAGE
  • UIAUTOMATION_TEST_PACKAGE
  • UIAUTOMATOR_TEST_PACKAGE
  • XCTEST_TEST_PACKAGE
  • XCTEST_UI_TEST_PACKAGE
  • APPIUM_JAVA_JUNIT_TEST_SPEC
  • APPIUM_JAVA_TESTNG_TEST_SPEC
  • APPIUM_PYTHON_TEST_SPEC
  • APPIUM_NODE_TEST_SPEC
  • APPIUM_RUBY_TEST_SPEC
  • APPIUM_WEB_JAVA_JUNIT_TEST_SPEC
  • APPIUM_WEB_JAVA_TESTNG_TEST_SPEC
  • APPIUM_WEB_PYTHON_TEST_SPEC
  • APPIUM_WEB_NODE_TEST_SPEC
  • APPIUM_WEB_RUBY_TEST_SPEC
  • INSTRUMENTATION_TEST_SPEC
  • XCTEST_UI_TEST_SPEC
If you call CreateUpload with WEB_APP specified, AWS Device Farm throws an ArgumentException error.

Parameter contentType : The upload's content type (for example, application/octet-stream).

Implementation

Future<CreateUploadResult> createUpload({
  required String name,
  required String projectArn,
  required UploadType type,
  String? contentType,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    0,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(projectArn, 'projectArn');
  _s.validateStringLength(
    'projectArn',
    projectArn,
    32,
    1011,
    isRequired: true,
  );
  ArgumentError.checkNotNull(type, 'type');
  _s.validateStringLength(
    'contentType',
    contentType,
    0,
    64,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'DeviceFarm_20150623.CreateUpload'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'name': name,
      'projectArn': projectArn,
      'type': type.toValue(),
      if (contentType != null) 'contentType': contentType,
    },
  );

  return CreateUploadResult.fromJson(jsonResponse.body);
}