MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / actionFileGet

Method actionFileGet

src/Ui/UiWebsocket.py:680–697  ·  view source on GitHub ↗
(self, to, inner_path, required=True, format="text", timeout=300)

Source from the content-addressed store, hash-verified

678 # Return file content
679 @flag.async_run
680 def actionFileGet(self, to, inner_path, required=True, format="text", timeout=300):
681 try:
682 if required or inner_path in self.site.bad_files:
683 with gevent.Timeout(timeout):
684 self.site.needFile(inner_path, priority=6)
685 body = self.site.storage.read(inner_path, "rb")
686 except (Exception, gevent.Timeout) as err:
687 self.log.error("%s fileGet error: %s" % (inner_path, Debug.formatException(err)))
688 body = None
689
690 if not body:
691 body = None
692 elif format == "base64":
693 import base64
694 body = base64.b64encode(body).decode()
695 else:
696 body = body.decode()
697 self.response(to, body)
698
699 @flag.async_run
700 def actionFileNeed(self, to, inner_path, timeout=300):

Callers

nothing calls this directly

Calls 4

responseMethod · 0.95
errorMethod · 0.80
needFileMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected