store method
this function will store the file in your project storage folder
RequestFile image = req.input('image');
String filename = await image.store();
Implementation
Future<String> store({String folder = 'storage'}) async {
String uid = uuid.v1();
String path =
_sanitizePath('${Directory.current.path}/$folder/$uid.$extension');
File file = File(path);
Directory directory = Directory(file.parent.path);
if (!directory.existsSync()) {
directory.createSync(recursive: true);
}
List<int> b = await bytes;
await file.writeAsBytes(b);
return file.path.replaceFirst(Directory.current.path, '');
}