Class ResumableUpload<TRequest> (1.60.0)

public class ResumableUpload<TRequest> : ResumableUpload

Media upload which uses Google's resumable media upload protocol to upload data.

Inheritance

object > ResumableUpload > ResumableUpload<TRequest>

Namespace

GoogleApisUpload

Assembly

Google.Apis.dll

Type Parameter

Name Description
TRequest

The type of the body of this request. Generally this should be the metadata related to the content to be uploaded. Must be serializable to/from JSON.

Remarks

See: https://developers.google.com/drive/manage-uploads#resumable for more information on the protocol.

Constructors

ResumableUpload(IClientService, string, string, Stream, string)

protected ResumableUpload(IClientService service, string path, string httpMethod, Stream contentStream, string contentType)

Create a resumable upload instance with the required parameters.

Parameters
Name Description
service IClientService

The client service.

path string

The path for this media upload method.

httpMethod string

The HTTP method to start this upload.

contentStream Stream

The stream containing the content to upload.

contentType string

Content type of the content to be uploaded. Some services may allow this to be null; others require a content type to be specified and will fail when the upload is started if the value is null.

Remarks

Caller is responsible for maintaining the contentStream open until the upload is completed. Caller is responsible for closing the contentStream.

Properties

Body

public TRequest Body { get; set; }

Gets or sets the body of this request.

Property Value
Type Description
TRequest

ContentType

public string ContentType { get; }

Gets or sets the stream's Content-Type.

Property Value
Type Description
string

HttpMethod

public string HttpMethod { get; }

Gets or sets the HTTP method of this upload (used to initialize the upload).

Property Value
Type Description
string

Path

public string Path { get; }

Gets or sets the path of the method (combined with BaseUri) to produce absolute Uri.

Property Value
Type Description
string

Service

public IClientService Service { get; }

Gets or sets the service.

Property Value
Type Description
IClientService

Methods

InitiateSessionAsync(CancellationToken)

public override Task<Uri> InitiateSessionAsync(CancellationToken cancellationToken = default)

Initiates the resumable upload session and returns the session URI, or upload URI. See https://developers.google.com/drive/manage-uploads#start-resumable and https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#start-resumable for more information.

Parameter
Name Description
cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns
Type Description
TaskUri

The task containing the session URI to use for the resumable upload.

Overrides

Extension Method