upload method
Future<GoogleBytestreamMedia>
upload(
- GoogleBytestreamMedia request,
- String resourceName, {
- String? $fields,
- Media? uploadMedia,
Uploads media.
Upload is supported on the URI
/upload/media/{resource_name=**}?upload_type=media.
Note: Upload
requests will not be successful without including upload_type=media
query string.
request
- The metadata request object.
Request parameters:
resourceName
- Name of the media that is being downloaded. See
ReadRequest.resource_name.
Value must have pattern ^.*$
.
$fields
- Selector specifying which fields to include in a partial
response.
uploadMedia
- The media to upload.
Completes with a GoogleBytestreamMedia.
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<GoogleBytestreamMedia> upload(
GoogleBytestreamMedia request,
core.String resourceName, {
core.String? $fields,
commons.Media? uploadMedia,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
core.String url_;
if (uploadMedia == null) {
url_ = 'media/' + core.Uri.encodeFull('$resourceName');
} else {
url_ = '/upload/media/' + core.Uri.encodeFull('$resourceName');
}
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
uploadMedia: uploadMedia,
uploadOptions: commons.UploadOptions.defaultOptions,
);
return GoogleBytestreamMedia.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}