def album(self): items = request.form['list'].split(",") for i in items: klass = RedisObject.klass(i) if not klass: # Does not exist return {'error': 404}, 404 if klass != File: # Wrong type return {'error': 415}, 415 if len(items) > 50: return {'error': 413}, 413 a = Album() a.items = items a.ip = secure_ip() a.save() return {"hash": a.hash}
def zip_album(h): a = Album.from_hash(h) paths = map(lambda f: file_storage(f.original), a.items) zip_path = file_storage(h + ".zip") if os.path.exists(zip_path): return call(["zip", "-j", zip_path] + paths) a.metadata = json.dumps({"has_zip": True}) a.save()
def album(self): items = request.form['list'].split(",") for i in items: klass = RedisObject.klass(i) if not klass: # Does not exist return {'error': 404}, 404 if klass != File: # Wrong type return {'error': 415}, 415 if len(items) > 1024: return {'error': 413}, 413 a = Album() a.items = items a.ip = secure_ip() a.metadata = json.dumps({'has_zip': False}) a.save() return {"hash": a.hash}