【问题标题】:Run html file from google cloud url从谷歌云 url 运行 html 文件
【发布时间】:2018-08-20 12:06:19
【问题描述】:

我已将我的 html 文件保存到具有公共读取权限的谷歌云存储中。 当我尝试打开 html 文件时,Chrome 会自动在本地下载 HTML 文件,而不是在浏览器选项卡中打开它。

Html 公共网址是: https://www.googleapis.com/download/storage/v1/b/presentationpublish/o/index_1112q_252_636703629560463983.html?generation=1534766167109567&alt=media

代码:

return storage.UploadObject(
       bucket: BucketName,
       objectName: objectName,
       contentType: "text/html",
       source: valStream,
       options: new UploadObjectOptions { PredefinedAcl = publicRead }
   );

【问题讨论】:

  • 可以设置chrome打开files

标签: c# html google-app-engine google-cloud-storage


【解决方案1】:

我找到了解决办法,我们可以用新的这样的来改变当前的网址:

var url=https://www.googleapis.com/download/storage/v1/b/presentationpublish/o/index_1112q_252_636703629560463983.html?generation=1534766167109567&alt=media

var new_url=url.replace("https://www.googleapis.com/download/storage/v1/b/", "https://storage.googleapis.com/").replace("/o/", "/");

现在它对我来说很好。

【讨论】:

    猜你喜欢
    • 2020-10-03
    • 2020-03-18
    • 2017-09-23
    • 1970-01-01
    • 2020-06-01
    • 2018-10-21
    • 2021-06-07
    • 2020-11-24
    • 2020-08-30
    相关资源
    最近更新 更多