I currently have a canvas on which I draw rectangles and save their coordinates. These coordinates are stored in a Javascript dictionary.
Through the script provided below, I am able to save/download a file containing the dictionary. However, it is only saved in the Downloads folder.
function myFunction() {
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' + encodeURI(JSON.stringify(dict));
hiddenElement.target = '_blank';
hiddenElement.download = 'dict.json';
hiddenElement.click();
}
My goal is to save this file in Django's media folder specific to each user.
The desired location should be: media > {{user}} > dict.json
Any assistance on achieving this would be greatly appreciated.