Forum Discussion
LauraShelley
7 years agoQrew Member
Dan, unfortunately your solution above doesn't seem to work properly with .jpg files for some reason. I'm not sure if Quickbase handles photo files differently or what...
I tried it the original way you have above, which resulted in an unreadable .jpg file named myfile.jpg.
I also tried this:
var Text fileExtension = Part([Photo], 2, ".");
"<a href='" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/' download='myfile." & $fileExtension & "'>Download Photo</a>"
This resulted in a download of the original file (not renamed). I'm using Chrome.
I tried it the original way you have above, which resulted in an unreadable .jpg file named myfile.jpg.
I also tried this:
var Text fileExtension = Part([Photo], 2, ".");
"<a href='" & URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/' download='myfile." & $fileExtension & "'>Download Photo</a>"
This resulted in a download of the original file (not renamed). I'm using Chrome.
LauraShelley
7 years agoQrew Member
The following solution works in a URL Formula Field. Thanks for your help, Dan! Very much appreciated!
var Text url = URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/";
var Text fileName = "Photo.jpg";
"javascript:fetch('" & $url & "',{credentials: 'include'}).then(response => response.blob()).then(blob => {var link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = '" & $fileName & "'; link.click();})"
var Text url = URLRoot() & "up/" & Dbid() & "/a/r" & [Record ID#] & "/e6/v0/";
var Text fileName = "Photo.jpg";
"javascript:fetch('" & $url & "',{credentials: 'include'}).then(response => response.blob()).then(blob => {var link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = '" & $fileName & "'; link.click();})"