def handle_uploaded_file(f, location): if f is not None: with open(location, 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk)