Skip to content
Snippets Groups Projects
Commit ddd02484 authored by Julian's avatar Julian
Browse files

Fix file upload and remove debug code

parent 1d468a20
Branches
No related tags found
No related merge requests found
......@@ -16,8 +16,11 @@ class Photo(db.Model):
def from_form(cls, filestorage):
obj = cls(mimetype='image/jpeg')
db.session.add(obj)
db.session.flush()
assert obj.id
obj.path = f'photos/{obj.id}'
path = os.path.join(current_app.config['UPLOAD_FOLDER'], obj.path)
assert not os.path.exists(path)
filestorage.save(path)
return obj
......@@ -26,9 +29,10 @@ class Photo(db.Model):
obj = cls(mimetype='image/jpeg')
db.session.add(obj)
db.session.flush()
assert obj.id
obj.path = f'photos/{obj.id}'
path = os.path.join(current_app.config['UPLOAD_FOLDER'], obj.path)
print(path)
assert not os.path.exists(path)
with open(path, 'wb') as f:
f.write(data)
return obj
......
......@@ -109,7 +109,6 @@ def ipp_request(uri, operation, *tags, data=b''):
conn.close()
major_version, minor_version, status, message_id = struct.unpack('>bbhi', resp_data[:8])
# TODO: decode tags/data
print('ipp', status, resp_data[8:])
return status
def print_pdf(pdf_data, printer_uri, job_name=None, validate_only=False):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment