From 529ebc4214c8c1871482336f97d4122d46b19910 Mon Sep 17 00:00:00 2001 From: Mardix Date: Mon, 10 Aug 2015 20:23:09 -0400 Subject: [PATCH] 0.11.0 - Added Object.full_url, removed Object.shorl_url --- CHANGELOG | 4 ++++ README.md | 17 +++++++++++++---- flask_cloudy.py | 36 ++++++++++++++++++++++++------------ setup.py | 2 +- tests/test_cloudy.py | 2 -- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3ca27f8..2b099c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +0.11.0 + - Removed flask_cloudy.Object.short_url now use flask_cloudy.Object.url + - Added flask_cloudy.Object.full_url to have the domain for local storage + 0.10.0 - Removed LOCAL_PATH configuration. Use CONTAINER as the LOCAL_PATH - Change config prefix to STORAGE_* diff --git a/README.md b/README.md index e357ff9..6d86880 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ AWS S3, Google Storage, Microsoft Azure, Rackspace Cloudfiles, and even Local fi For local file storage, it also provides a flask endpoint to access the files. + +Version: 0.11.* + --- ##TLDR; Quick Example @@ -406,12 +409,17 @@ The extension of the object ##### Object.url -Get the full url of the object +Return the url of the object +On LOCAL, it will return the url without the domain name ( ie: /files/my-file.jpg ) -##### Object.short_url +For cloud providers it will return the full url -Specially for LOCAL provider, it will return the url without the domain. +##### Object.full_url + +Returns the full url of the object + +Specially for LOCAL provider, it will return the url with the domain. For cloud providers, it will return the full url just like **Object.url** @@ -420,6 +428,7 @@ For cloud providers, it will return the full url just like **Object.url** Return a secured url, with **https://** + ##### Object.path The path of the object relative to the container @@ -461,7 +470,7 @@ To save the object to a local path ##### Object.download_url(timeout=60, name=None) -Return a URL that triggers the browser download of the file. +Return a URL that triggers the browser download of the file. On cloud providers it will return a signed url. - timeout: int - The time in seconds to give access to the url diff --git a/flask_cloudy.py b/flask_cloudy.py index d7c931b..6cacdf5 100644 --- a/flask_cloudy.py +++ b/flask_cloudy.py @@ -448,24 +448,24 @@ class Object(object): def url(self): """ Returns the url of the object. - For local it will return it with the domain name - :return: - """ - return self.get_url(longurl=True) - - @property - def short_url(self): - """ - Returns the url of the object - For local it will return it WITHOUT the domain name - :return: + For Local it will return it without the domain name + :return: str """ return self.get_url() + @property + def full_url(self): + """ + Returns the full url with the domain, specially for Local storage + :return: str + """ + return self.get_url(longurl=True) + + @property def secure_url(self): """ - Return a url with https + Return the full url with https :return: """ return self.get_url(secure=True, longurl=True) @@ -564,3 +564,15 @@ class Object(object): raise NotImplemented("This provider '%s' doesn't support or " "doesn't have a signed url " "implemented yet" % self.provider_name) + + @property + def short_url(self): + """ + DEPRECATED + + Returns the url of the object + For local it will return it WITHOUT the domain name + :return: + """ + warnings.warn("DEPRECATED: flask_cloudy.Object.short_url has been deprecated, use flask_cloudy.Object.url or flask_cloudy.Object.full_url") + return self.get_url() \ No newline at end of file diff --git a/setup.py b/setup.py index f53cfc8..ead3481 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ Supported storage: from setuptools import setup, find_packages __NAME__ = "Flask-Cloudy" -__version__ = "0.10.0" +__version__ = "0.11.0" __author__ = "Mardix" __license__ = "MIT" __copyright__ = "2015" diff --git a/tests/test_cloudy.py b/tests/test_cloudy.py index 4eecc10..a87f9d3 100644 --- a/tests/test_cloudy.py +++ b/tests/test_cloudy.py @@ -165,5 +165,3 @@ def test_save_to(): assert os.path.isfile(file) assert file2 == CWD + "/data/my_new_file.txt" - -from flask_cloudy import Storage \ No newline at end of file