createDirectUpload method

Future<CloudflareHTTPResponse<DataUploadDraft?>> createDirectUpload({
  1. bool? requireSignedURLs,
  2. Map<String, dynamic>? metadata,
  3. DateTime? expiry,
})

Direct uploads allow users to upload images 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 Cloudflare Images. Method creates a draft record for a future image and returns upload URL and image identifier that can be used later to verify if image itself has been uploaded or not with the draft: true property in the image response.

Documentation: https://api.cloudflare.com/#cloudflare-images-create-authenticated-direct-upload-url-v2

Implementation

Future<CloudflareHTTPResponse<DataUploadDraft?>> createDirectUpload({
  /// Indicates whether the image requires a signature token for the access
  ///
  /// Default value: false
  /// e.g: true
  bool? requireSignedURLs,

  /// User modifiable key-value store. Can use used for keeping references to
  /// another system of record for managing images.
  ///
  /// e.g: "{\"meta\": \"metaID\"}"
  Map<String, dynamic>? metadata,

  /// 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(
      requireSignedURLs: requireSignedURLs,
      metadata: metadata,
      expiry: expiry?.toJson(),
    ),
    dataType: DataUploadDraft(),
  );
  return response;
}