1

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 public url is: https://www.googleapis.com/download/storage/v1/b/presentationpublish/o/index_1112q_252_636703629560463983.html?generation=1534766167109567&alt=media

code:

return storage.UploadObject(
       bucket: BucketName,
       objectName: objectName,
       contentType: "text/html",
       source: valStream,
       options: new UploadObjectOptions { PredefinedAcl = publicRead }
   );
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
Harry
  • 21
  • 5
  • 1
    you can set chrome to open [files](https://ccm.net/faq/36268-google-chrome-how-to-clear-auto-opening-settings) – IteratioN7T Aug 20 '18 at 13:01

1 Answers1

1

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

Now it's working fine for me.

Harry
  • 21
  • 5