Already got to this point before starting this post…
As I said my problem is that the text is dynamic and every user can enter a different text so a template can’t work for me as I don’t know in advance where the commas will be as well as I can’t do for the spaces and as I’m using fetch for the images and not uploading to cloudinary my image must be encoded as well .
On the sheet side I just encoded the image and used substitute function to change any comma in the text dynamically with what you just sent and then encoding the whole text to create a url that is compliant
It doesn’t really matter that the text is dynamic - just run it through a template similar to the one I posted just now and the commas will be encoded wherever they appear.
@yinon_raviv I did a sample app recently where I auto-uploaded the images to Cloudinary - and thereafter deleted the images from Glide keeping the storage low in Glide. Kind of prefer that to fetch as fetch images are put in the root of the cloudinary account.
There are some differences between fetch and auto-upload - maybe you already know those.
As I’m sure you’re aware, you need to Base64 encode images when using fetch.
If you can find a way to do that in Glide I’ll be super-impressed, but it’s trivial with Apps Script.
Here’s a short snippet that I use for Base64 encoding:
var file = DriveApp.getFileById(file_id);
var blob = file.getBlob();
var file_string = Utilities.base64Encode(blob.getBytes());
You just need to give it the GDrive FileID, which is easy enough to get.
Thanks, yes, I’m aware and actually have a different script for the base64 which is just if you use overlay image, in case if one image, regular encoding suffice.
I did not find a way to do this is glide and 8 think this is to complex to convert to glide.
I did manage to regular encode an image for the fetch for 1 image only with replacing in glide template all the slashes (/) with a %2F which works perfectly.
It seems my base64 encoding script has the tendency to break and stop working occasionally…
Does your script stable?
If so, will be happy to implement it instead of mine with a little guidance from you
When you say it needs to be deleted and pasted again, I assume you’re referring to the values in the spreadsheet, yes?
This is a fairly common problem with custom functions, and for that reason I’m not a big fan.
I’d recommend using a trigger instead. Without seeing what your sheet looks like, I’d probably do something like this:
Add another column to the sheet to hold a timestamp - “Encoded At”
Each time the trigger runs, check every row that holds the text to be encoded
If the corresponding timestamp column is empty, then encode the text in that row and write the current time to the timestamp column
The thing about this approach is if it fails once for any row (due to a transient sheets error), then the timestamp won’t be written and it should then pick it up on the next run.
I can be available for a call, if you’d like to talk it through, just PM me.