Skip to content
This repository was archived by the owner on Jul 7, 2021. It is now read-only.

Commit 84b7692

Browse files
committed
Update code to handle new API endpoints
1 parent eb4e3ae commit 84b7692

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="siaskynet",
8-
version="0.0.2",
8+
version="0.0.5",
99
author="Peter-Jan Brone",
1010
author_email="[email protected]",
1111
description="Skynet SDK",
@@ -21,4 +21,4 @@
2121
"Operating System :: OS Independent",
2222
],
2323
python_requires='>=3.6',
24-
)
24+
)

siaskynet/skynet.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import random
2+
import string
3+
14
import requests
25

6+
37
class Skynet:
48
@staticmethod
59
def default_upload_options():
610
return type('obj', (object,), {
711
'portalUrl': 'https://siasky.net',
8-
'portalUploadPath' : '/api/skyfile',
12+
'portalUploadPath' : 'skynet/skyfile',
913
'portalFileFieldname' : 'file',
1014
'customFilename':''
1115
})
@@ -27,8 +31,11 @@ def UploadFile(path, opts=None):
2731
if opts is None:
2832
opts = Skynet.default_upload_options()
2933

34+
charset = string.ascii_lowercase
35+
uuid = ''.join(random.choice(charset) for i in range(16))
36+
3037
with open(path, 'rb') as f:
31-
r = requests.post("%s%s" % (opts.portalUrl, opts.portalUploadPath), files={opts.portalFileFieldname: f})
38+
r = requests.post("%s/%s/%s" % (opts.portalUrl, opts.portalUploadPath, uuid), files={opts.portalFileFieldname: f})
3239
response = r.json()
3340
return "sia://" + response["skylink"]
3441

0 commit comments

Comments
 (0)