从Google Cloud URL运行HTML文件 [英] Run html file from google cloud url

查看:143
本文介绍了从Google Cloud URL运行HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have saved my html file into google cloud storage with public read permission. When I am trying to open html file, Chrome automatically downloads the HTML files locally and does not open it in a browser tab.

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

Html public url is: 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 }
   );

推荐答案

我找到了解决方案,我们可以使用以下新名称更改当前网址:

I found the solution, we can change the current url with new like:

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/", "/");

现在对我来说很好.

这篇关于从Google Cloud URL运行HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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