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

Add maxDurationSeconds and Expiry for TUS Uploads #1399

Open
bbbshah opened this issue Sep 13, 2023 · 0 comments
Open

Add maxDurationSeconds and Expiry for TUS Uploads #1399

bbbshah opened this issue Sep 13, 2023 · 0 comments

Comments

@bbbshah
Copy link
Contributor

bbbshah commented Sep 13, 2023

Current cloudflare-go version

0.77.0

Description

stream.StreamInitiateTUSVideoUpload currently allows you create a video stream
for upload using TUS protocol. Due to lack of maxDurationSeconds, the streams
created (for direct_user=true) results in maxDurationSeconds=14400 which
takes the video billing quota until the video is uploaded. This PR adds supports to
pass additional params MaxDurationSeconds and Expiry in TUSUploadMetadata
to add appropriate functionality to the newly created stream/video.

Use cases

When creating multiple direct_user=true TUS uploads, it's necessary to explicitly
pass the duration of the video to accurately account against the quota. Lack of this
functionality results in default maxDurationSeconds that quickly takes the quota,
often resulting in error due to over budget.

Potential cloudflare-go usage

params := cloudflare.StreamInitiateTUSUploadParameters{
    DirectUserUpload: true,
    TusResumable:     cloudflare.TusProtocolVersion1_0_0,
    UploadLength:     *input.UploadLengthBytes,
    Metadata: cf.TUSUploadMetadata{
        Name:                  *input.Name,
        RequireSignedURLs:     true,
        ThumbnailTimestampPct: 0.1,
        MaxDurationSeconds:    *input.Duration,
        Expiry:                &inTwoHours,
    },
}

res, err := cloudflare.StreamInitiateTUSVideoUpload(context, cloudflare.AccountIdentifier(CLOUDFLARE_ACCOUNT_ID), params)
if err != nil {
    // TODO: handle error
}

References

No response

@bbbshah bbbshah changed the title Add maxDurationSeconds and Expiry for TUS Uploads Add maxDurationSeconds and Expiry for TUS Uploads Sep 13, 2023
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 a pull request may close this issue.

1 participant