You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* tus support for direct creator uploads
* revised tus section based on kyle's feedback
based on feedback from #483
* updated to use bearer token
* Update direct-creator-uploads.md
* tus capitaliation
Copy file name to clipboardExpand all lines: products/stream/src/content/uploading-videos/direct-creator-uploads.md
+60-1Lines changed: 60 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,11 @@ Additionally, you can control security features through these fields:
51
51
52
52
</Definitions>
53
53
54
-
### Example request
54
+
## Using Basic Uploads
55
+
56
+
If the uploads from your creators are under 200MB, you can use basic uploads. For videos over 200 MB, use TUS uploads (described later in this article.)
57
+
58
+
The first step is to request a token by calling the `direct_upload` end point from your server:
55
59
56
60
```bash
57
61
curl -X POST \
@@ -172,6 +176,61 @@ size, the user will receive a `4xx` response.
172
176
173
177
</Example>
174
178
179
+
## Using tus (recommended for videos over 200MB)
180
+
181
+
tus is a protocol that supports resumable uploads and works best for larger files.
182
+
183
+
Typically, tus uploads require the authentication information to be sent with every request. This is not ideal for direct creators uploads because it exposes your API key (or token) to the end user.
184
+
185
+
To get around this, you can request a one-time tokenized URL by making a POST request to the `/stream?direct_user=true` end point:
return new Response(null, {headers: {'Access-Control-Expose-Headers':'Location','Access-Control-Allow-Headers':'*','Access-Control-Allow-Origin':'*','location':results}})
218
+
219
+
}
220
+
221
+
async function gatherResponse(response) {
222
+
const { headers } = response
223
+
return await headers.get('location')
224
+
225
+
}
226
+
```
227
+
228
+
You can apply the same constraints as Direct Creator Upload via basic upload: expiry and maxDurationSeconds. To do so, you must pass the expiry and maxDurationSeconds as part of the `Upload-Metadata` request header as part of the first request (made by the Worker in the example above.) The `Upload-Metadata` values are ignored from subsequent requests that do the actual file upload.
229
+
230
+
Once you have the tokenized URL, you can pass it to the tus client to begin the upload. For details on using a tus client, refer to the [Resumable uploads with tus ](https://developers.cloudflare.com/stream/uploading-videos/upload-video-file#resumable-uploads-with-tus-for-large-files) article.
231
+
232
+
If you simply want to do a test upload with a tokenized url, visit the [tus codepen demo](https://codepen.io/cfzf/pen/wvGMRXe) and paste the returned url in the "Upload endpoint" field.
233
+
175
234
## Tracking user upload progress
176
235
177
236
After the creation of a unique one-time upload URL, you may wish to retain the
0 commit comments