UploadTask.fromFile constructor
UploadTask.fromFile({
- required File file,
- String? taskId,
- required String url,
- Map<
String, String> ? urlQueryParameters, - Map<
String, String> ? headers, - String? httpRequestMethod,
- String? post,
- String fileField = 'file',
- String? mimeType,
- Map<
String, String> ? fields, - String group = 'default',
- Updates updates = Updates.status,
- bool requiresWiFi = false,
- int retries = 0,
- int priority = 5,
- String metaData = '',
- String displayName = '',
- DateTime? creationTime,
Creates UploadTask from a File object, using the file
absolute path.
Note that using absolute paths is discouraged on mobile, as the path to files in an application's directory scope is not stable between application starts. Use the combination of baseDirectory, directory and filename whenever possible to prevent hard to debug errors.
Implementation
UploadTask.fromFile(
{required File file,
super.taskId,
required super.url,
super.urlQueryParameters,
super.headers,
String? httpRequestMethod,
String? super.post,
this.fileField = 'file',
String? mimeType,
Map<String, String>? fields,
super.group,
super.updates,
super.requiresWiFi,
super.retries,
super.priority,
super.metaData,
super.displayName,
super.creationTime})
: fields = fields ?? {},
mimeType =
mimeType ?? lookupMimeType(file.path) ?? 'application/octet-stream',
super(
baseDirectory: BaseDirectory.root,
directory: p.dirname(file.absolute.path),
filename: p.basename(file.absolute.path),
httpRequestMethod: httpRequestMethod ?? 'POST',
allowPause: false);