-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewItem.py
More file actions
32 lines (29 loc) · 949 Bytes
/
Copy pathNewItem.py
File metadata and controls
32 lines (29 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import datetime
import Helpers
def NewItem(filename : str, client, sig : str, tf : bool):
if tf:
file = open(str(filename), 'a')
sig = sig + '\n'
writee = [str(datetime.datetime.now()), '\n', sig]
file.writelines(writee)
file.close()
item = client.add(str(filename))
Helpers.addItem('doc', str(filename), Helpers.getHash(item, 'None', False), 'spacedb')
return item
def GetFile(client, item):
if type(item) == str:
getfile = client.cat(item)
getfile = getfile.decode('utf-8')
return getfile
elif type(item) == dict:
hash = item["Hash"]
getfile = client.cat(str(hash))
getfile = getfile.decode('utf-8')
return getfile
else:
return False
#client = ipfshttpclient.connect()
#hash = NewItem('./yeet.txt', client, 'Bot', True)
#print(hash)
#hash = dict(hash)
#print(GetFile(client, hash))