As you all probably know, google hosting is going away at the end of the month. However I've got the impression that the webcontentlink meta property of a file will still work as a link to an image.

To get the link by apps script, you need to enable the advanced drive service, and you can get the webcontent link as per this app. So you can have a little webapp to tell you the url for any file which you can then copy into your html code.

function doGet(e) {

var id = e && e.parameter && ? : "id missing";
var mode = e && e.parameter && e.parameter.mode ? e.parameter.mode : "details";
var file = getWebContentLink(id);

if (mode === "image") {
return HtmlService
.createHtmlOutput('<img src="' + file.webContentLink + '">')
else {
return ContentService
function getWebContentLink(id) {
// Drive.Files.get(fileId)
return Drive.Files.get(id, {


You can then use the webcontentlink as the url for the hosted file and it seems to work.

Im not sure what'll happen with unsigned in users. For a test, I've published this webapp to run as me, so i'm assuming it will work on any files you've got as public.

If anyone wants to have a go, then here's the app - this modes returns detail on the file so you can use the link.

this one renders the image

any thoughts?

#gde #googleappsscript #blogpost
Shared publiclyView activity