MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / download_file

Method download_file

utils.py:818–835  ·  view source on GitHub ↗
(self, handler)

Source from the content-addressed store, hash-verified

816 handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8'))
817
818 def download_file(self, handler):
819 try:
820 query = unquote(handler.path.split('?path=')[1])
821 file_path = os.path.join(self.shared_data.datastolendir, query)
822 if os.path.isfile(file_path):
823 handler.send_response(200)
824 handler.send_header("Content-Disposition", f'attachment; filename="{os.path.basename(file_path)}"')
825 handler.end_headers()
826 with open(file_path, 'rb') as file:
827 handler.wfile.write(file.read())
828 else:
829 handler.send_response(404)
830 handler.end_headers()
831 except Exception as e:
832 handler.send_response(500)
833 handler.send_header("Content-type", "application/json")
834 handler.end_headers()
835 handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8'))
836
837 def get_all_credentials(self):
838 """Get all discovered credentials from various services"""

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
readMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected