从url下载文件,保存到手机存储 [英] Download file from url, save to phones storage

查看:25
本文介绍了从url下载文件,保存到手机存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个项目,需要我从 URL 下载文件,一旦点击按钮,并将其存储到手机存储(可能是下载文件夹).

I'm working on a project, that requires me to download a file from URL, once a button is tapped, and store it to phone storage (probably downloads folder).

关于如何做到这一点的任何想法?正在下载的文件也不总是相同的,可以是从图像到 pdf 的任何文件.

Any ideas on how to do this? The file that is being downloaded is also not always the same and can be anything from an image to a pdf.

推荐答案

使用 https://pub.dartlang.org/packages/flutter_downloader.不要忘记进行平台配置.

Use https://pub.dartlang.org/packages/flutter_downloader. Don't forget to do platform configurations.

基本上,这就是您应该如何使用该软件包.链接中有详细的长示例.

Basically, this is how you should use the package. There is a detailed long example in the link.

final taskId = await FlutterDownloader.enqueue(
  url: 'your download link',
  savedDir: 'the path of directory where you want to save downloaded files',
  showNotification: true, // show download progress in status bar (for Android)
  openFileFromNotification: true, // click on notification to open downloaded file (for Android)
);

有人说上面的包维护得很好.试试这个https://pub.dev/packages/flowder

Some people said the package on top is to well maintained. Try this one https://pub.dev/packages/flowder

这篇关于从url下载文件,保存到手机存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆