A module that makes File Transfer a bit easier.
Project description
FileTransfer
A python module that makes file transfer slightly easier
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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4ddef19bb30af5fa1b1871ef7578a22bfb9c0798b14e353f3b1b3702a93c23f |
|
MD5 | 7b193447160ac3e79ec789d4e13a304c |
|
BLAKE2b-256 | 36a7912b05059cd4de550f87eda06b5fe9b62feb62e509beb222bd11b0711889 |
Close
Hashes for FileTransfer_LQR471814-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9002605723b1b945618c39fc3992cae90976024fdc65447f729dfb8fa08fbd1 |
|
MD5 | b7ebf801652b10b233a2239a6752e38a |
|
BLAKE2b-256 | b1c48f3aeb8e098970f2e226b293f99eced206acda69b3721446ada3468f26af |