Class ResumableUpload<TRequest>
Media upload which uses Google's resumable media upload protocol to upload data.
Inherited Members
Namespace: Google.Apis.Upload
Assembly: Google.Apis.dll
Syntax
public class ResumableUpload<TRequest> : ResumableUpload
Type Parameters
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)
Create a resumable upload instance with the required parameters.
Declaration
protected ResumableUpload(IClientService service, string path, string httpMethod, Stream contentStream, string contentType)
Parameters
Type | Name | Description |
---|---|---|
IClientService | service | The client service. |
string | path | The path for this media upload method. |
string | httpMethod | The HTTP method to start this upload. |
Stream | contentStream | The stream containing the content to upload. |
string | contentType | 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
Gets or sets the body of this request.
Declaration
public TRequest Body { get; set; }
Property Value
Type | Description |
---|---|
TRequest |
ContentType
Gets or sets the stream's Content-Type.
Declaration
public string ContentType { get; }
Property Value
Type | Description |
---|---|
string |
HttpMethod
Gets or sets the HTTP method of this upload (used to initialize the upload).
Declaration
public string HttpMethod { get; }
Property Value
Type | Description |
---|---|
string |
Path
Gets or sets the path of the method (combined with BaseUri) to produce absolute Uri.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
string |
Service
Gets or sets the service.
Declaration
public IClientService Service { get; }
Property Value
Type | Description |
---|---|
IClientService |
Methods
InitiateSessionAsync(CancellationToken)
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.
Declaration
public override Task<Uri> InitiateSessionAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task<Uri> | The task containing the session URI to use for the resumable upload. |