def process_upload_multiple(files, callback_url=None): id = utils.generate_id() d = utils.storage_dir_for_id(id) os.makedirs(d) file_id = 0 session = database.Session() m = database.model(id, '') session.add(m) for file in files: fn = file.filename filewriter = lambda fn: file.save(fn) filewriter(os.path.join(d, id + "_" + str(file_id) + ".ifc")) file_id += 1 m.files.append(database.file(id, '')) session.commit() session.close() if DEVELOPMENT: t = threading.Thread( target=lambda: worker.process_multiple(id, callback_url)) t.start() else: q.enqueue(worker.process_multiple, id, callback_url) return id
def process_upload(filewriter, callback_url=None): id = utils.generate_id() d = utils.storage_dir_for_id(id) os.makedirs(d) filewriter(os.path.join(d, id + ".ifc")) session = database.Session() session.add(database.model(id, '')) session.commit() session.close() if DEVELOPMENT: t = threading.Thread(target=lambda: worker.process(id, callback_url)) t.start() else: q.enqueue(worker.process, id, callback_url) return id