Skip to content

Commit 97202e7

Browse files
committed
socket transfer done and download incorporated
1 parent 712d1cb commit 97202e7

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ Records a Vox(A 10 second audio clip) to share with your friends
55

66

77

8-
# UPLOAD.py
8+
# upload.py
99

1010
Class : TransferData
1111
methods:
1212
-> upload_file(local_file, upload_directory)
1313
-> download_file(download_cloud_directory)
14+
15+
# soc_ket.py
16+
17+
Class : Exchange
18+
methods:
19+
-> Receive(ipaddress for server)
20+
-> Send(ipaddress of the server ,message)

soc_ket.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import socket as s
2+
import sys
3+
import upload as u
4+
5+
class Exchange:
6+
def receive(self, host='0.0.0.0'):
7+
PORT_NUMBER = 7899
8+
SIZE = 1024
9+
try:
10+
host = s.gethostbyname(host)
11+
except:
12+
pass
13+
14+
mySocket = s.socket(s.AF_INET, s.SOCK_DGRAM)
15+
mySocket.bind((host, PORT_NUMBER))
16+
17+
(data, addr) = mySocket.recvfrom(SIZE)
18+
data=data.decode('utf-8')
19+
downloader = u.TransferData()
20+
downloader.download_file(data)
21+
22+
23+
def send(self, server, link):
24+
SERVER_IP = server
25+
PORT_NUMBER = 7899
26+
SIZE = 1024
27+
print("Test client sending packets to IP {0}, via port {1}\n".format(
28+
SERVER_IP, PORT_NUMBER))
29+
30+
mySocket = s.socket(s.AF_INET, s.SOCK_DGRAM)
31+
32+
mySocket.sendto(link.encode('utf-8'), (SERVER_IP, PORT_NUMBER))
33+

upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class TransferData:
55
def __init__(self):
66
self.access_token = '4gc0YhoYYVAAAAAAAAAACsHBfiNVDgSKDbtCOnJQRaR77j0rwVuMOoUbCnxSbJJY'
77

8-
def __init__(self, access_token):
9-
self.access_token = access_token
8+
# def __init__(self, access_token):
9+
# self.access_token = access_token
1010

1111
def upload_file(self, file_from, file_to):
1212
"""upload a file to Dropbox using API v2

0 commit comments

Comments
 (0)