Reputation: 5107
I am getting the path of an image from the device storage, like this:
path = res[0]?.path;
print("path:"+path);
The output of that print is:
/data/user/0/qplan/cache/image_picker_b432f88b-3146-4a99-9e8b-acbefd066e3a2471538209034937554.jpeg
I need to convert it to File in order to upload the image to Firestore Storage.
Upvotes: 1
Views: 901
Reputation: 180
You can use this.
import 'dart:async';
import 'dart:io';
path = res[0]?.path;
File(path).readAsString().then((String contents) {
print(contents);
});
Upvotes: 2
Reputation: 1702
You can get file inserting your path to File object as below;
File fileToUpload = new File(path);
Upvotes: 2