-
Notifications
You must be signed in to change notification settings - Fork 597
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
adds support to initiate streams upload using tus #1359
adds support to initiate streams upload using tus #1359
Conversation
changelog detected ✅ |
…o-initiate-tus-upload
@jacobbednarz Would you be able to take a look at this PR when you get a chance? Thank you in advance! |
stream.go
Outdated
type StreamInitiateTUSUploadParameters struct { | ||
DirectUserUpload bool | ||
TusResumable TusProtocolVersion | ||
UploadLength int64 | ||
UploadCreator string | ||
Metadata TUSUploadMetadata | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type StreamInitiateTUSUploadParameters struct { | |
DirectUserUpload bool | |
TusResumable TusProtocolVersion | |
UploadLength int64 | |
UploadCreator string | |
Metadata TUSUploadMetadata | |
} | |
type StreamInitiateTUSUploadParameters struct { | |
DirectUserUpload bool `url:"direct_user,omitempty"` | |
TusResumable TusProtocolVersion `url:"-"` | |
UploadLength int64 `url:"-"` | |
UploadCreator string `url:"-"` | |
Metadata TUSUploadMetadata `url:"-"` | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows us to use the struct for query parameter building in buildURI
instead of manually performing it.
stream.go
Outdated
uri := fmt.Sprintf("/accounts/%s/stream", rc.Identifier) | ||
if params.DirectUserUpload { | ||
uri += "?direct_user=true" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uri := fmt.Sprintf("/accounts/%s/stream", rc.Identifier) | |
if params.DirectUserUpload { | |
uri += "?direct_user=true" | |
} | |
uri := buildURI(fmt.Sprintf("/accounts/%s/stream", rc.Identifier), params) |
stream_test.go
Outdated
if r.URL.Query().Get("direct_user") == "true" { | ||
w.Header().Set("Location", "https://upload.videodelivery.net/tus/90c68cb5cd4fd5350b1962279c90bec0?tusv2=true") | ||
} else { | ||
w.Header().Set("Location", "https://production.gateway.api.cloudflare.com/client/v4/accounts/test-account-id/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w.Header().Set("Location", "https://production.gateway.api.cloudflare.com/client/v4/accounts/test-account-id/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true") | |
w.Header().Set("Location", "https://api.cloudflare.com/client/v4/accounts/"+testAccountID+"/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true") |
stream_test.go
Outdated
|
||
out, err := client.StreamInitiateTUSVideoUpload(context.Background(), AccountIdentifier(testAccountID), params) | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, "https://production.gateway.api.cloudflare.com/client/v4/accounts/test-account-id/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true", out.ResponseHeaders.Get("Location")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.Equal(t, "https://production.gateway.api.cloudflare.com/client/v4/accounts/test-account-id/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true", out.ResponseHeaders.Get("Location")) | |
assert.Equal(t, "https://api.cloudflare.com/client/v4/accounts/"+testAccountID+"/media/278f2a7e763c73dedc064b965d2cfbed?tusv2=true", out.ResponseHeaders.Get("Location")) |
this looks good, thanks! for future PRs, i recommend clicking the "allow maintainers to make changes" checkbox to save the back and forth here and we can apply small edits like the above ones without having to do the extra round trip. |
Codecov Report
@@ Coverage Diff @@
## master #1359 +/- ##
==========================================
+ Coverage 48.33% 48.41% +0.08%
==========================================
Files 133 139 +6
Lines 13023 13809 +786
==========================================
+ Hits 6295 6686 +391
- Misses 5201 5466 +265
- Partials 1527 1657 +130
|
This functionality has been released in v0.77.0. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Adds support to streams to initiate tus video upload.
Description
The current api client doesn't support streams: initiate tus video upload.
This PR adds a new func
StreamInitiateTUSVideoUpload
tostreams.go
.Has your change been tested?
Added unit tests for the newly added functions.
Types of changes
What sort of change does your code introduce/modify?
Checklist:
and relies on stable APIs.