MultiUploadTask constructor

MultiUploadTask({
  1. String? taskId,
  2. required String url,
  3. Map<String, String>? urlQueryParameters,
  4. required List files,
  5. Map<String, String>? headers,
  6. String? httpRequestMethod,
  7. Map<String, String>? fields = const {},
  8. String directory = '',
  9. BaseDirectory baseDirectory = BaseDirectory.applicationDocuments,
  10. String group = 'default',
  11. Updates updates = Updates.status,
  12. bool requiresWiFi = false,
  13. int priority = 5,
  14. int retries = 0,
  15. String metaData = '',
  16. String displayName = '',
  17. DateTime? creationTime,
})

Creates UploadTask

taskId must be unique. A unique id will be generated if omitted url properly encoded if necessary, can include query parameters urlQueryParameters may be added and will be appended to the url, must be properly encoded if necessary files list of objects representing each file to upload. The object must be either a String representing the filename/path (and the fileField will be the filename without extension), a Record of type (String fileField, String filename/path) or a Record with a third String for the mimeType (if omitted, mimeType will be derived from the filename extension). Each file must be based in the directory represented by the combination of baseDirectory and directory, unless a full filepath is given instead of only the filename. For example: "hello.txt" or "/data/com.myapp/data/dir/hello.txt" headers an optional map of HTTP request headers httpRequestMethod the HTTP request method used (e.g. GET, POST) fields optional map of name/value pairs to upload along with the file as form fields directory optional directory name, precedes filename baseDirectory one of the base directories, precedes directory group if set allows different callbacks or processing for different groups updates the kind of progress updates requested requiresWiFi if set, will not start upload until WiFi is available. If not set may start upload over cellular network priority in range 0 <= priority <= 10 with 0 highest, defaults to 5 retries if >0 will retry a failed upload this many times metaData user data displayName human readable name for this task creationTime time of task creation, 'now' by default.

Implementation

MultiUploadTask(
    {super.taskId,
    required super.url,
    super.urlQueryParameters,
    required List<dynamic> files,
    super.headers,
    super.httpRequestMethod,
    super.fields = const {},
    super.directory,
    super.baseDirectory,
    super.group,
    super.updates,
    super.requiresWiFi,
    super.priority,
    super.retries,
    super.metaData,
    super.displayName,
    super.creationTime})
    : fileFields = files
          .map((e) => switch (e) {
                String filename => p.basenameWithoutExtension(filename),
                (String fileField, String _, String _) => fileField,
                (String fileField, String _) => fileField,
                _ => throw ArgumentError(_filesArgumentError)
              })
          .toList(growable: false),
      filenames = files
          .map((e) => switch (e) {
                String filename => filename,
                (String _, String filename, String _) => filename,
                (String _, String filename) => filename,
                _ => throw ArgumentError(_filesArgumentError)
              })
          .toList(growable: false),
      mimeTypes = files
          .map((e) => switch (e) {
                (String _, String _, String mimeType) => mimeType,
                String filename ||
                (String _, String filename) =>
                  lookupMimeType(filename) ?? 'application/octet-stream',
                _ => throw ArgumentError(_filesArgumentError)
              })
          .toList(growable: false),
      super(filename: 'multi-upload', fileField: '', mimeType: '');