A module that makes File Transfer a bit easier.
Project description
FileTransfer
A python module that makes file transfer slightly easier
pip install FileTransfer
Syntax
FileTransfer.send(filepath="", socket=s)
FileTransfer.receive(destination_folder_path="", socket=s)
Usage
Sending
import socket
import FileTransfer as ft
# Setup socket for use in file transfer
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect("ip.address", port)
ft.send(filepath, s) # Specify filepath as str and use client socket object
Receiving
import socket
import FileTransfer as ft
# Setup simple socket receive
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("0.0.0.0", port))
s.listen(1)
conn, addr = s.accept()
result = ft.receive("C:\\destination\\folder\\path\\", conn) # Invoke receive function
# Result is a tuple with the file contents being index 0 and filename being index 1
print("Filename: ", result[1], "File Contents: ", result[0])
Protocol (TCP)
Filename Length | Filename | Payload Length (File Contents Length) | Payload (File Contents) |
---|---|---|---|
4 Bytes |
Filename encoded (utf8) |
4 bytes |
Payload bytes |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for FileTransfer-LQR471814-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5462269c89f8a340843d6bc7b567a6a503895c9ba6a68a9c34e0d77f92d87432 |
|
MD5 | 78640b6768aad34b0c47c6c4082da994 |
|
BLAKE2b-256 | 5895ef1103a9835ceaa1c8a10a5cdac009691201d5b514085ad9407bcac4d8fb |
Close
Hashes for FileTransfer_LQR471814-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de784ca182e9c10b9775bfbd4d6ee5c7750f6c41983576efb52762506437e233 |
|
MD5 | fe21b046df29e4a21593dbab10c3da37 |
|
BLAKE2b-256 | 69ba6f5844cd15b28b85974d3d7804313735f5d993a37c39eb9df6e42f0810c2 |