How can i upload file with url

it not work for me, why

dt and dn, are not available in the file manager and check the all field name of the file manager.

And please share the code and paste it here.


I don’t do that direction, because the URL I want to save when I download it, I can see it but when uploaded to Frappe, I can’t see

other URL: “

So I took another URL to download the file and then upload it to Frappe and have a problem when using Request.get () to get the location in the header, this location is not exactly when I do it in the browser.

@frappe.whitelist(allow_guest = True)
def download_and_upload_file(url, doctype, docname):
        response = requests.get(url, allow_redirects=False)
        if response.is_redirect or response.status_code in (301, 302):
            redirect_url = response.headers.get('Location')
            # this localtion different with browser
            if redirect_url:
                final_response = requests.get(redirect_url)
                if final_response.status_code == 200:
                    new_filename = "downloaded_audio.wav"
                    with open(new_filename, 'wb') as file:
                        print("File downloaded and saved as:", new_filename)

                    with open(new_filename, 'rb') as f:
                        fname = "hello.wav"
                        content =
                        save_file(fname, content, doctype, docname)
                        print("File uploaded to Frappe")
                    print("Failed to download the file. Status code:", response.status_code)
    except Exception as e:
        print("An error occurred:", str(e))

when i print location in code:

and this is location in browser