Skip to main content

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) : Returns void

FileTransfer.receive(socket=s) : Returns bytes

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(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.

Source Distribution

FileTransfer-LQR471814-0.1.2.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

FileTransfer_LQR471814-0.1.2-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page