/// <summary> /// Creates a <see cref="ResumableUpload"/> instance for a resumable upload session which has already been initiated. /// </summary> /// <remarks> /// See https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#start-resumable for more information about initiating /// resumable upload sessions and saving the session URI, or upload URI. /// </remarks> /// <param name="uploadUri">The session URI of the resumable upload session. Must not be null.</param> /// <param name="contentStream">The data to be uploaded. Must not be null.</param> /// <param name="options">The options for the upload operation. May be null.</param> /// <returns>The instance which can be used to upload the specified content.</returns> public static ResumableUpload CreateFromUploadUri( Uri uploadUri, Stream contentStream, ResumableUploadOptions options = null) { uploadUri.ThrowIfNull(nameof(uploadUri)); return(new InitiatedResumableUpload(uploadUri, contentStream, options)); }
/// <summary> /// Creates a <see cref="ResumableUpload"/> instance. /// </summary> /// <param name="contentStream">The data to be uploaded. Must not be null.</param> /// <param name="options">The options for the upload operation. May be null.</param> protected ResumableUpload(Stream contentStream, ResumableUploadOptions options) { contentStream.ThrowIfNull(nameof(contentStream)); ContentStream = contentStream; // Check if the stream length is known. StreamLength = ContentStream.CanSeek ? ContentStream.Length : UnknownSize; HttpClient = options?.ConfigurableHttpClient ?? new HttpClientFactory().CreateHttpClient(new CreateHttpClientArgs { ApplicationName = "ResumableUpload", GZipEnabled = true }); Options = options; }
public InitiatedResumableUpload(Uri uploadUri, Stream contentStream, ResumableUploadOptions options) : base(contentStream, options) { _initiatedUploadUri = uploadUri; }