String function to create URL not working in module

Hi

I’m trying to create an URL I can embed into a Notion page, from the Web View Link supplied by Google Drive when I upload a file.

I understand that Notion cannot handle the URL that Google Drive supplies as it’s a link to a page to view the file, rather than a link to the file itself.

I’m am trying to extract the FILE_ID so I can create a new URL which I can embed, however the substring function seems to be doing nothing when I test my scenario.

The file(s) are upload to Google Drive and a parent page is create in Notion but whatever processing I try to do to the Web View link to extract the file ID, nothing happens and the module fails with “Invalid URL”.

The pic shows me testing just trying to extract the file ID.

What am I doing wrong here?!


Thanks

Stuart

Hey @Stuart_Mingay,

Just a quick question, but is there any specific reason why you want to extract the file ID from the web view link? Normally speaking all GDrive modules should also return the File ID (see example below):
image

So you should be able to get it directly from there.

That said, the substring solution would also work (as would a regex solution for that matter). But I think you’re making it a bit too complex with the use of toString() and the quotation marks around your text.

If you structure your formula like this, it should work as well:

image
image

note that the text you’re grabbing the index of is not between quotation marks. And the + is using the {{+}} notation so that Make knows it’s a mathematical function.

Let me know if that helps :slight_smile:

2 Likes

Hey @NolaDigital

Ah, that would be better. Didn’t see the File ID in there!

But thanks also for the formatting help: I was including the tostring() as part of my troubleshooting to be honest. I’ll redo the string hacking to get it to work, but then go and use the fileid from the Google Drive module.

Thanks

Stuart

Hey again @NolaDigital

I continued with the substring route and I still couldn’t get the functions to split out the ID from the URL given. The Notion module still errored with the same error and the URL was left unchanged in the output.

So I tried using the file ID direct from Google Drive, and added it to the end of a string like this:

image

… but it still failed. It’s worth noting these are all PNG image files I’m trying to manipulate.

Thanks again!

Stuart

You may need to update the permissions of the file to be “public” for Notion to “see” it… or it may be that notion requires the image to end with an image extension (jpg/png/etc)

Likely needs to the extension - according to Notion API docs:

Best Bet…

You might try making an EMBED “type” (if you can within make, im not 100% sure)

Here you could “embed” the image via the following URL Structure

First you’d need to set the image to public (i’m fairly sure)

Then you’d need to add the file ID to the following URL structure…

https://drive.google.com/file/d/---THEFILEID---/preview
Note, this may not be the final structure, just a quick google search, you may have to use a different URL structure

Lastly just include the link in the embed in notion:

Last idea is to upload the file to a platform such as bunny.net (added expense) and hosting the raw .jpg/png file and adding that as the URL. Currently notion doesn’t support uploading files directly via the API

2 Likes

Lovely. Thank you for your help here.

I made the GCS public and then Notion could see the images and embed them. A bit worrying from a security point of view!

Thanks again

Stuart

2 Likes