Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def download_remote_file(file_url, file_path=None):
- if file_path == None:
- file_path = BASE_ROOT + '/templates/static/assets/uploads/'
- response = requests.get(file_url, stream=True)
- file_extension = file_url.split('.')[-1]
- random_file_name = get_random_token(file_url)
- full_file_name = random_file_name + "." + file_extension
- with open(file_path + full_file_name, 'wb') as out_file:
- shutil.copyfileobj(response.raw, out_file)
- del response
- return full_file_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement