diff --git a/flask_cloudy.py b/flask_cloudy.py index 5bb7ee3..d1c2365 100644 --- a/flask_cloudy.py +++ b/flask_cloudy.py @@ -308,7 +308,7 @@ class Storage(object): raise InvalidExtensionError("Invalid file extension: '.%s' " % extension) if isinstance(file, FileStorage): - obj = self.container.upload_object_via_stream(iterator=file, + obj = self.container.upload_object_via_stream(iterator=file.stream, object_name=name, extra=extra) else: diff --git a/setup.py b/setup.py index ba8c19c..ed5ae20 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ setup( packages=find_packages(), install_requires=[ "Flask==0.10.1", - "apache-libcloud==0.17.0", + "apache-libcloud==0.19.0", "lockfile==0.10.2", "shortuuid==0.1", "six==1.9.0", diff --git a/tests/test_cloudy.py b/tests/test_cloudy.py index 9f5c027..c777d45 100644 --- a/tests/test_cloudy.py +++ b/tests/test_cloudy.py @@ -165,3 +165,19 @@ def test_save_to(): assert os.path.isfile(file) assert file2 == CWD + "/data/my_new_file.txt" +def test_werkzeug_upload(): + try: + import werkzeug + except ImportError: + return + storage = app_storage() + object_name = "my-txt-hello.txt" + filepath = CWD + "/data/hello.txt" + file = None + with open(filepath, 'rb') as fp: + file = werkzeug.datastructures.FileStorage(fp) + file.filename = object_name + o = storage.upload(file, overwrite=True) + assert isinstance(o, Object) + assert o.name == object_name +