createDirectStreamUpload method
Direct uploads allow users to upload videos without API keys. A common place to use direct uploads is on web apps, client side applications, or on mobile devices where users upload content directly to Stream.
Documentation: https://api.cloudflare.com/#stream-videos-upload-videos-via-direct-upload-urls
Implementation
Future<CloudflareHTTPResponse<DataUploadDraft?>> createDirectStreamUpload({
/// Direct uploads occupy minutes of videos on your Stream account until
/// they are expired. This value will be used to calculate the duration the
/// video will occupy before the video is uploaded. After upload, the
/// duration of the uploaded will be used instead. If a video longer than
/// this value is uploaded, the video will result in an error.
///
/// Min value: 1 second
/// Max value: 21600 seconds which is 360 mins, 6 hours
/// e.g: 300 seconds which is 5 mins
required int maxDurationSeconds,
/// User-defined identifier of the media creator
///
/// Max length: 64
/// e.g: "creator-id_abcde12345"
String? creator,
/// Timestamp location of 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 will be
/// from 0s of the video.
///
/// Default value: 0
/// Min value:0
/// Max value:1
/// e.g: 0.529241
num? thumbnailTimestampPct,
/// List which origins should be allowed to display the video. Enter
/// allowed origin domains in an array and use * for wildcard subdomains.
/// Empty array will allow the video to be viewed on any origin.
///
/// e.g:
/// [
/// "example.com"
/// ]
List<String>? allowedOrigins,
/// Indicates whether the video can be a accessed only using it's UID. If
/// set to true, a signed token needs to be generated with a signing key to
/// view the video.
///
/// Default value: false
/// e.g: true
bool? requireSignedURLs,
/// A Watermark object with the id of an existing watermark profile
/// e.g: Watermark(id: "ea95132c15732412d22c1476fa83f27a")
Watermark? watermark,
/// The date after upload will not be accepted.
///
/// Min value: Now + 2 minutes.
/// Max value: Now + 6 hours.
/// Default value: Now + 30 minutes.
/// e.g: "2021-01-02T02:20:00Z"
DateTime? expiry,
}) async {
assert(!isBasic, RestAPIService.authorizedRequestAssertMessage);
final response = await genericParseResponse(
service.createDirectUpload(
data: {
Params.maxDurationSeconds: maxDurationSeconds,
Params.creator: creator,
Params.thumbnailTimestampPct: thumbnailTimestampPct,
Params.allowedOrigins: allowedOrigins,
Params.requireSignedURLs: requireSignedURLs,
Params.watermark: watermark?.toJson(),
Params.expiry: expiry?.toJson(),
}..removeWhere(
(key, value) => value == null || (value is List && value.isEmpty)),
),
dataType: DataUploadDraft(),
);
return response;
}