Upload videos from a URL
Uploads a video to Stream from a provided URL.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Accepted Permissions (at least one required)
Parameters
A video's URL. The server must be publicly routable and support HTTP HEAD requests and HTTP GET range requests. The server should respond to HTTP HEAD requests with a content-range header that includes the size of the file.
Lists the origins allowed to display the video. Enter allowed origin domains in an array and use * for wildcard subdomains. Empty arrays allow the video to be viewed on any origin.
Indicates whether the video can be a accessed using the UID. When set to true, a signed token must be generated with a signing key to view the video.
Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a null value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time.
The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video.
Upload videos from a URL
import os
from cloudflare import Cloudflare
client = Cloudflare(
api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted
)
video = client.stream.copy.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
url="https://example.com/myvideo.mp4",
)
print(video.uid){
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {
"allowedOrigins": [
"example.com"
],
"created": "2014-01-02T02:20:00Z",
"creator": "creator-id_abcde12345",
"duration": 0,
"input": {
"height": 0,
"width": 0
},
"liveInput": "fc0a8dc887b16759bfd9ad922230a014",
"maxDurationSeconds": 1,
"meta": {
"name": "video12345.mp4"
},
"modified": "2014-01-02T02:20:00Z",
"playback": {
"dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd",
"hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8"
},
"preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch",
"readyToStream": true,
"readyToStreamAt": "2014-01-02T02:20:00Z",
"requireSignedURLs": true,
"scheduledDeletion": "2014-01-02T02:20:00Z",
"size": 4190963,
"status": {
"errorReasonCode": "ERR_NON_VIDEO",
"errorReasonText": "The file was not recognized as a valid video file.",
"pctComplete": "pctComplete",
"state": "inprogress"
},
"thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg",
"thumbnailTimestampPct": 0.529241,
"uid": "ea95132c15732412d22c1476fa83f27a",
"uploaded": "2014-01-02T02:20:00Z",
"uploadExpiry": "2014-01-02T02:20:00Z",
"watermark": {
"created": "2014-01-02T02:20:00Z",
"downloadedFrom": "https://company.com/logo.png",
"height": 0,
"name": "Marketing Videos",
"opacity": 0.75,
"padding": 0.1,
"position": "center",
"scale": 0.1,
"size": 29472,
"uid": "ea95132c15732412d22c1476fa83f27a",
"width": 0
}
}
}