Forum Discussion
LauraShelley
Qrew 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.
_anomDiebolt_
6 years agoQrew Elite
Use this version and then spontaneously break into a celebratory cubicle dance:
You can test this by navigating to the Pastie Database and pasting the code into the console.
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=691
function download(url, fileName) {
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 url = "https://haversineconsulting.quickbase.com/up/bm3ttgwp6/g/rb/eg/va/rythm.mp3";
var fileName = "Kryptonite.mp3";
download(url, fileName);
You can test this by navigating to the Pastie Database and pasting the code into the console.
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=691