/// <summary> /// Creates a <see cref="SignedUrlResumableUpload"/> instance. /// </summary> /// <param name="signedUrl"> /// The signed URL which can be used to initiate a resumable upload session. See /// <see cref="UrlSigner.ResumableHttpMethod">UrlSigner.ResumableHttpMethod</see> for more information. /// </param> /// <param name="contentStream">The data to be uploaded.</param> /// <param name="options">The options for the upload operation.</param> /// <returns>The instance which can be used to upload the specified content.</returns> public static SignedUrlResumableUpload Create( string signedUrl, Stream contentStream, ResumableUploadOptions options = null) { return(new SignedUrlResumableUpload( GaxPreconditions.CheckNotNull(signedUrl, nameof(signedUrl)), contentStream, options)); }
/// <summary> /// Initiates the resumable upload session by posting to the signed URL and returns the session URI. /// </summary> /// <param name="signedUrl"> /// The signed URL which can be used to initiate a resumable upload session. See /// <see cref="UrlSigner.ResumableHttpMethod">UrlSigner.ResumableHttpMethod</see> for more information. /// </param> /// <param name="options">The options for the upload operation.</param> /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> /// <returns> /// A task containing the session URI to use for the resumable upload. /// </returns> public static Task <Uri> InitiateSessionAsync( string signedUrl, ResumableUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { // We need an instance to call ExceptionForResponseAsync if the initiate request fails, so create a // temporary instance to initiate the session. var uploader = new SignedUrlResumableUpload(signedUrl, new MemoryStream(), options); return(uploader.InitiateSessionAsync(cancellationToken)); }
/// <summary> /// Initiates the resumable upload session by posting to the signed URL and returns the session URI. /// </summary> /// <param name="signedUrl"> /// The signed URL which can be used to initiate a resumable upload session. See /// <see cref="UrlSigner.ResumableHttpMethod">UrlSigner.ResumableHttpMethod</see> for more information. /// </param> /// <param name="options">The options for the upload operation.</param> /// <returns> /// The session URI to use for the resumable upload. /// </returns> public static Uri InitiateSession(string signedUrl, ResumableUploadOptions options = null) => InitiateSessionAsync(signedUrl, options).ResultWithUnwrappedExceptions();
private SignedUrlResumableUpload(string signedUrl, Stream contentStream, ResumableUploadOptions options) : base(contentStream, options) { SignedUrl = signedUrl; }