adds support to initiate streams upload using tus#1359
adds support to initiate streams upload using tus#1359jacobbednarz merged 11 commits intocloudflare:masterfrom MemReel:feature/stream-video-initiate-tus-upload
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! |
| type StreamInitiateTUSUploadParameters struct { | ||
| DirectUserUpload bool | ||
| TusResumable TusProtocolVersion | ||
| UploadLength int64 | ||
| UploadCreator string | ||
| Metadata TUSUploadMetadata | ||
| } |
There was a problem hiding this comment.
| 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.
this allows us to use the struct for query parameter building in buildURI instead of manually performing it.
| uri := fmt.Sprintf("/accounts/%s/stream", rc.Identifier) | ||
| if params.DirectUserUpload { | ||
| uri += "?direct_user=true" | ||
| } |
There was a problem hiding this comment.
| 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) |
| 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.
| 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") |
|
|
||
| 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.
| 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
StreamInitiateTUSVideoUploadtostreams.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.