MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / storbinary

Method storbinary

tools/python-3.11.9-amd64/Lib/ftplib.py:482–509  ·  view source on GitHub ↗

Store a file in binary mode. A new port is created for you. Args: cmd: A STOR command. fp: A file-like object with a read(num_bytes) method. blocksize: The maximum data size to read from fp and send over the connection at once. [def

(self, cmd, fp, blocksize=8192, callback=None, rest=None)

Source from the content-addressed store, hash-verified

480 return self.voidresp()
481
482 def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
483 """Store a file in binary mode. A new port is created for you.
484
485 Args:
486 cmd: A STOR command.
487 fp: A file-like object with a read(num_bytes) method.
488 blocksize: The maximum data size to read from fp and send over
489 the connection at once. [default: 8192]
490 callback: An optional single parameter callable that is called on
491 each block of data after it is sent. [default: None]
492 rest: Passed to transfercmd(). [default: None]
493
494 Returns:
495 The response code.
496 """
497 self.voidcmd('TYPE I')
498 with self.transfercmd(cmd, rest) as conn:
499 while 1:
500 buf = fp.read(blocksize)
501 if not buf:
502 break
503 conn.sendall(buf)
504 if callback:
505 callback(buf)
506 # shutdown ssl layer
507 if _SSLSocket is not None and isinstance(conn, _SSLSocket):
508 conn.unwrap()
509 return self.voidresp()
510
511 def storlines(self, cmd, fp, callback=None):
512 """Store a file in line mode. A new port is created for you.

Callers

nothing calls this directly

Calls 7

voidcmdMethod · 0.95
transfercmdMethod · 0.95
voidrespMethod · 0.95
callbackFunction · 0.70
readMethod · 0.45
sendallMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected