MCPcopy
hub / github.com/scrapy/scrapy / persist_file

Method persist_file

scrapy/pipelines/files.py:381–401  ·  view source on GitHub ↗
(
        self,
        path: str,
        buf: BytesIO,
        info: MediaPipeline.SpiderInfo,
        meta: dict[str, Any] | None = None,
        headers: dict[str, str] | None = None,
    )

Source from the content-addressed store, hash-verified

379 self.basedir: str = u.path.rstrip("/")
380
381 def persist_file(
382 self,
383 path: str,
384 buf: BytesIO,
385 info: MediaPipeline.SpiderInfo,
386 meta: dict[str, Any] | None = None,
387 headers: dict[str, str] | None = None,
388 ) -> Deferred[Any]:
389 path = f"{self.basedir}/{path}"
390 return deferred_from_coro(
391 run_in_thread(
392 ftp_store_file,
393 path=path,
394 file=buf,
395 host=self.host,
396 port=self.port,
397 username=self.username,
398 password=self.password,
399 use_active_mode=bool(self.USE_ACTIVE_MODE),
400 )
401 )
402
403 def _stat_file(self, path: str) -> StatInfo:
404 try:

Callers 1

test_persistMethod · 0.95

Calls 2

deferred_from_coroFunction · 0.90
run_in_threadFunction · 0.90

Tested by 1

test_persistMethod · 0.76