Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow a new upload session to be initiated as a single method call #12054

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

jskeet
Copy link
Collaborator

@jskeet jskeet commented Mar 5, 2024

This allows the content length to be (optionally) specified, which is then propagated via X-Upload-Content-Length.

This is currently just a prototype for comment - I'd want to add integration tests, some unit tests, and obviously XML docs.

See #12034 for background.

@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 5, 2024
@jskeet jskeet requested review from a team as code owners March 5, 2024 14:49
@jskeet jskeet force-pushed the initiate-upload-session branch from d5d4508 to a888e06 Compare March 5, 2024 14:51
Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to include the UploadObjectOptions as a parameter to these new methods, and then include the length in the UploadObjectOptions. We'd use the options slightly diferent in these methods, as the length field would be used to create the source (empty) stream instead of to modify the uploader, but I think that's fine, options are still surfaced in a consistent manner. And we would have to fail if both a stream and a lenght are provided, which is also fine I think. It's ugly implementation wise though.

Also, we could update this snippet to be simpler

@jskeet
Copy link
Collaborator Author

jskeet commented Mar 5, 2024

I think it would be useful to include the UploadObjectOptions as a parameter to these new methods, and then include the length in the UploadObjectOptions. We'd use the options slightly diferent in these methods, as the length field would be used to create the source (empty) stream instead of to modify the uploader, but I think that's fine, options are still surfaced in a consistent manner. And we would have to fail if both a stream and a lenght are provided, which is also fine I think. It's ugly implementation wise though.

Also, we could update this snippet to be simpler

I'll have a look at how much of UploadObjectOptions would actually be relevant. I thought most of it wouldn't be, but I could be wrong. Will look tomorrow.

@jskeet
Copy link
Collaborator Author

jskeet commented Mar 6, 2024

Right, having looked, I can see that UploadObjectOptions does indeed have a bunch of stuff in that would be relevant.

I think my personal preference would still be to have a separate method accepting the length and an UploadObjectOptions rather than putting the length into the options directly. I'll amend the PR with my preference for this, and we can then discuss it further. (I may have misunderstood your proposal.)

Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this looks good.

@jskeet
Copy link
Collaborator Author

jskeet commented Mar 6, 2024

Great - will do all the rest of the work tomorrow, thanks !

@jskeet jskeet force-pushed the initiate-upload-session branch from 839dc4e to d12a473 Compare March 7, 2024 15:47
@jskeet jskeet removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 7, 2024
@jskeet
Copy link
Collaborator Author

jskeet commented Mar 7, 2024

Okay, this is now ready for proper review.

It's currently only the async methods. I suspect we could add synchronous methods just by calling .ResultWithUnwrappedExceptions() - that's what we do in SignedUrlResumableUpload. (We may also want to provide the ability to specify a length in SignedUrlResumableUpload as well at some point.)

I'm happy to either add the sync methods in here, or wait until they're requested.

Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit only.

I'm fine with adding the sync versions later if there's demand for it.

/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <param name="options">Additional options for the upload. May be null, in which case appropriate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: swap these two? I thought Visual Studio would catch that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, yes, will do.

This allows the content length to be (optionally) specified, which is then
propagated via X-Upload-Content-Length.
@jskeet jskeet force-pushed the initiate-upload-session branch from d12a473 to b8bf052 Compare March 7, 2024 17:27
@jskeet jskeet merged commit f0b643e into googleapis:main Mar 7, 2024
10 checks passed
@jskeet jskeet deleted the initiate-upload-session branch March 7, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants