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

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

问题描述

我正在研究一个项目,要求我点击一个按钮后,从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到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.

推荐答案

使用< a href = https://pub.dartlang.org/packages/flutter_downloader rel = noreferrer> https://pub.dartlang.org/packages/flutter_downloader 。

基本上,这就是您应该使用软件包的方式。链接中有一个详细的长示例。

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)
);

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

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