首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拒绝接受403访问权限打开Firebase存储下载网址

拒绝接受403访问权限打开Firebase存储下载网址
EN

Stack Overflow用户
提问于 2022-01-20 10:16:46
回答 1查看 168关注 0票数 1

我正在上传PDF在我的应用程序到Firebase存储。

现在我想在浏览器中打开我的应用程序中的PDF格式。为此,我尝试像这样使用启动器

代码语言:javascript
复制
Future<void> _launchURL(
  BuildContext context, {
  required String url,
  String? errorMessage,
}) async {
  if (await canLaunch(url) == true) {
    await launch(Uri.encodeFull(url));
  }
}

但是当打开URL时,我得到以下信息:

代码语言:javascript
复制
{
  "error": {
    "code": 403,
    "message": "Permission denied."
  }
}

如果将我的Storage Rules设置为allow: read, write;,我将得到一个404-error。将我的launch更改为:

代码语言:javascript
复制
Future<void> _launchURL(
  BuildContext context, {
  required String url,
  String? errorMessage,
}) async {
  if (await canLaunch(url) == true) {
    await launch(url);  // <- without encoding
  }
}

我得到了一个Platform-Exeption

未处理的异常:PlatformException(错误,启动https://firebasestorage.googleapis.com/v0/b/appflug.appspot.com/o/studs%2FladSXGLivhRtVlJh3vogjXoxCdj1%2FlanguageTest%2FwIcon.pdf?alt=media&token=403f9631-58ed-4931-b76c-b9e6253e7d25时出错,null,null)

,但它正在网络上工作!。它实际上也是在我的iOS设备上打开我的浏览器中的PDF,但是它正在抛出.

我遗漏了什么?如何在downloadUrl、Android和Web上的浏览器中从Firebase Storage打开一个iOS?

EN

回答 1

Stack Overflow用户

发布于 2022-04-30 20:40:47

这两种方法都适用于我使用6.1.0版本的启动器

代码语言:javascript
复制
Future<void> launchInWebViewWithoutJavaScript(String url) async {
  final Uri toLaunch = Uri.parse(url);
  if (!await launchUrl(
    toLaunch,
    mode: LaunchMode.inAppWebView,
    webViewConfiguration: const WebViewConfiguration(enableJavaScript: false),
  )) {
    throw 'Could not launch $url';
  }
}

然后你也可以用这个:

代码语言:javascript
复制
Future<void> launchInWebViewOrVC(String url) async {
  final Uri toLaunch = Uri.parse(url);

  if (!await launchUrl(
    toLaunch,
    mode: LaunchMode.inAppWebView,
    webViewConfiguration: const WebViewConfiguration(
        headers: <String, String>{'my_header_key': 'my_header_value'}),
  )) {
    throw 'Could not launch $url';
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70784391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档