Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for FileTransfer-LQR471814, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size FileTransfer_LQR471814-0.1.1-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page