Flutter: Copy image file from url to firebase -
i'm trying copy user profile picture external service onto firebase server. far have:
final file file = await new file.fromuri(uri.parse(auth.currentuser.photourl)).create(); final storagereference ref = firebasestorage.instance.ref().child("profile_image_${auth.currentuser.uid}.jpg"); final storageuploadtask uploadtask = ref.put(file); final uri downloadurl = (await uploadtask.future).downloadurl; // add user profile picture url user object final userreference = firebasedatabase.instance .reference() .child('users/' + auth.currentuser.uid); userreference.set({'photourl': downloadurl});
the top line gives me error: unsupported operation: cannot extract file path https uri
what correct way this? should done client-side? (should passing url firebase , use function download server-side?)
file
supports files on file system. load content using http use http
package. see https://flutter.io/networking/
var httpclient = createhttpclient(); var response = await httpclient.get(url);
and data response.body
, or
var response = await httpclient.readbytes(url);
to binary (uint8list
)
see https://www.dartdocs.org/documentation/http/0.11.3+14/http/client-class.html
Comments
Post a Comment