首页 > 解决方案 > 如何从 Flutter Web 应用程序共享 S3 存储桶上的图像?

问题描述

在应用程序的移动版本上,我使用的是esys flutter share 包

这是我正在使用的片段:

() async {
                    var request = await HttpClient()
                        .getUrl(Uri.parse(product.imageUrl));
                    var response = await request.close();
                    Uint8List bytes =
                        await consolidateHttpClientResponseBytes(response);
                    await Share.file(
                        'Text to show?', 'amlog.jpg', bytes, 'image/jpg',
                        text: '${product.name}\nSolo por $finalPrice');
                  }

不幸的是,这个包不支持 Web 平台。

有一个包叫share plus 2.0

在示例中,他们说可以通过以下方式共享文件:

Share.shareFiles(['${directory.path}/image.jpg'], text: 'Great picture');
Share.shareFiles(['${directory.path}/image1.jpg', '${directory.path}/image2.jpg']);

但是,就我而言,该文件位于 S3 上。我需要将它下载到某个应用程序文件夹中。因为我的应用程序是 Web 我不知道如何下载图片并存储在应用程序的文件夹中。这可能吗?还有其他方法可以实现我想要的吗?

标签: flutterdartflutter-web

解决方案


将下载的文件保存在变量中,然后将其推送到您需要的地方。


推荐阅读