def distribution_file(dist, dist_file): app = flask.current_app # Generate all the hashes for this file hashes = {} for algorithm in hashlib.algorithms: hashes[algorithm] = getattr(hashlib, algorithm)(dist_file).hexdigest() # Save our file storage = get_storage(app=app) filename = storage.save(dist.filename, io.BytesIO(dist_file)) # Store our information on the model dist.hashes = hashes dist.file = filename
def uri(self): storage = get_storage() return storage.url(self.file)