uploadData method

Future<Upload> uploadData(
  1. String accountId,
  2. String webPropertyId,
  3. String customDataSourceId, {
  4. String? $fields,
  5. UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  6. Media? uploadMedia,
})

Upload data for a custom data source.

Request parameters:

accountId - Account Id associated with the upload. Value must have pattern \d+.

webPropertyId - Web property UA-string associated with the upload. Value must have pattern UA-\d+-\d+.

customDataSourceId - Custom data source Id to which the data being uploaded belongs.

$fields - Selector specifying which fields to include in a partial response.

uploadMedia - The media to upload.

uploadOptions - Options for the media upload. Streaming Media without the length being known ahead of time is only supported via resumable uploads.

Completes with a Upload.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Upload> uploadData(
  core.String accountId,
  core.String webPropertyId,
  core.String customDataSourceId, {
  core.String? $fields,
  commons.UploadOptions uploadOptions = commons.UploadOptions.defaultOptions,
  commons.Media? uploadMedia,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  core.String url_;
  if (uploadMedia == null) {
    url_ = 'management/accounts/' +
        commons.escapeVariable('$accountId') +
        '/webproperties/' +
        commons.escapeVariable('$webPropertyId') +
        '/customDataSources/' +
        commons.escapeVariable('$customDataSourceId') +
        '/uploads';
  } else if (uploadOptions is commons.ResumableUploadOptions) {
    url_ = '/resumable/upload/analytics/v3/management/accounts/' +
        commons.escapeVariable('$accountId') +
        '/webproperties/' +
        commons.escapeVariable('$webPropertyId') +
        '/customDataSources/' +
        commons.escapeVariable('$customDataSourceId') +
        '/uploads';
  } else {
    url_ = '/upload/analytics/v3/management/accounts/' +
        commons.escapeVariable('$accountId') +
        '/webproperties/' +
        commons.escapeVariable('$webPropertyId') +
        '/customDataSources/' +
        commons.escapeVariable('$customDataSourceId') +
        '/uploads';
  }

  final response_ = await _requester.request(
    url_,
    'POST',
    queryParams: queryParams_,
    uploadMedia: uploadMedia,
    uploadOptions: uploadOptions,
  );
  return Upload.fromJson(response_ as core.Map<core.String, core.dynamic>);
}