diff --git a/tinify/result.py b/tinify/result.py index aa2d694..68f8737 100644 --- a/tinify/result.py +++ b/tinify/result.py @@ -2,12 +2,17 @@ from __future__ import absolute_import, division, print_function, unicode_literals from . import ResultMeta +from google.appengine.ext import ndb class Result(ResultMeta): def __init__(self, meta, data): ResultMeta.__init__(self, meta) self.data = data + def to_blob(self, key): + img_store = key.get() + img_store.img = self.data + def to_file(self, path): if hasattr(path, 'write'): path.write(self.data) diff --git a/tinify/source.py b/tinify/source.py index 36c4301..09d010e 100644 --- a/tinify/source.py +++ b/tinify/source.py @@ -3,6 +3,7 @@ import tinify from . import Result, ResultMeta +from google.appengine.ext import ndb class Source(object): @classmethod @@ -44,6 +45,9 @@ def result(self): response = tinify.get_client().request('GET', self.url, self.commands) return Result(response.headers, response.content) + def to_blob(self, key): + return self.result().to_blob(key) + def to_file(self, path): return self.result().to_file(path)