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

NameDescription
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
NameDescription
serviceIClientService

The client service.

pathstring

The path for this media upload method.

httpMethodstring

The HTTP method to start this upload.

contentStreamStream

The stream containing the content to upload.

contentTypestring

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
TypeDescription
TRequest

ContentType

public string ContentType { get; }

Gets or sets the stream's Content-Type.

Property Value
TypeDescription
string

HttpMethod

public string HttpMethod { get; }

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

Property Value
TypeDescription
string

Path

public string Path { get; }

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

Property Value
TypeDescription
string

Service

public IClientService Service { get; }

Gets or sets the service.

Property Value
TypeDescription
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
NameDescription
cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
TaskUri

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

Overrides

Extension Method