This will work for any link generally, but my need was for the building of the link for an image being distributed with Cloudfront.
I am assuming that the addition of Epnoic Time to the front of the file name is something done for storage outside of Tadabase but regardless I updated to insert the Epoch Time to the file name front and attached to the form submit button so the link should most always be accurate. I suspect there will be occasions.
Assuming you have Tadabase configured to S3 and Cloudfront set up.
$('#FORM_ID button').click(function(){
var linkTxt = $('SELECTOR FOR FILE').html();
consLink = linkTxt.replace(/\s/g, '+');
newTime = Math.floor(new Date()/1000);
$('#INPUT_SLECTOR input').val('dhd3cpwcjod41.cloudfront.net/72Np3lorwv/'+ newTime + '-' + consLink).trigger('change');
});
Change the â+â in the replace method if you need as I needed the blank spaces to be a plus sign.
Hope it helps save someone a bit of time somewhere.
@moe - I have tried to think if there would be security concerns with putting your Cloudfront domain in the script and havenât thought of any, so yell if you do.
Also, if you see how I can tie the trigger to the change in the file upload state that would be better than using the text field. I just used the description as we grab the data anyway.