diff --git a/upload.py b/upload.py index d1a9b6c..f358677 100644 --- a/upload.py +++ b/upload.py @@ -44,20 +44,21 @@ def upload_file(): script_path = os.path.dirname(os.path.abspath(__file__)) temp_path = script_path + "\\temp\\" + + #a lot of stuff can wrong here and nobody may know with tempfile.NamedTemporaryFile(dir=temp_path, delete=False) as fp: fp.write(upload.stream.read()) path = fp.name fp.close() nc.put_file("/GIA CLOUD/" + filename, "temp\\" + path.split("\\")[-1]) - os.remove(fp.name) + os.remove(fp.name) #get public link - link = nc.share_file_with_link("/GIA CLOUD/" + filename) - print(link) - - #update db - #predpostavlja title, ir, owner_id, item_location - #card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=link, ) - #dbsession.add(card) - #dbsession.commit() + public_link = nc.share_file_with_link("/GIA CLOUD/" + filename).get_link()+"/download/"+filename + + #add card + card = Card(title=filename, interest_rate=-1.0, owner_id=user_id, item_location=public_link, last_review=None) + dbsession.add(card) + dbsession.commit() + return render_template("menu/upload.html", message=message, user_id=user_id, username=username) \ No newline at end of file