Class ResumableUpload<TRequest> (1.50.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

Google.Apis.Upload

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 = null)

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
Task<Uri>

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

Overrides

Extension Method