FetchData.fromFile constructor
Read the FetchData from a file where
pathToData
is the path to the file
containing the data to send.
pathToData
may be relative or absolute.
If the mimeType isn't passed then we use the file
extension to determine the mimeType
if that fails
we revert to text/plain.
throws FetchException if the file at pathToData
does not exist or it is not a file.
Implementation
FetchData.fromFile(String pathToData, {String? mimeType})
: _pathToDataFile = pathToData,
_type = _FetchDataType.path,
_mimeType = mimeType ?? lookupMimeType(pathToData) ?? 'text/plain' {
if (!exists(pathToData)) {
throw FetchException('${core.truepath(pathToData)} does not exist');
}
if (!isFile(pathToData)) {
throw FetchException('${core.truepath(pathToData)} is not a file');
}
}