Create binary files for images
This commit is contained in:
1 parent
e9094d4c6c
commit
6ec420db86
2 files changed
+3
-3
No files matched your search
@@ -69,12 +69,12 @@ class Plugin(object):
|
|||||||
d = os.path.join(self.plugin_path, 'static')
|
d = os.path.join(self.plugin_path, 'static')
|
||||||
return send_from_directory(d, filename)
|
return send_from_directory(d, filename)
|
||||||
|
|
||||||
def createFile(self, path, content):
|
def createFile(self, path, content, binary = False):
|
||||||
|
|
||||||
self.makeDir(os.path.dirname(path))
|
self.makeDir(os.path.dirname(path))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(path, 'w')
|
f = open(path, 'w' if not binary else 'wb')
|
||||||
f.write(content)
|
f.write(content)
|
||||||
f.close()
|
f.close()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class FileManager(Plugin):
|
|||||||
dest = os.path.join(Env.get('cache_dir'), '%s.%s' % (md5(url), getExt(url)))
|
dest = os.path.join(Env.get('cache_dir'), '%s.%s' % (md5(url), getExt(url)))
|
||||||
|
|
||||||
if overwrite or not os.path.isfile(dest):
|
if overwrite or not os.path.isfile(dest):
|
||||||
self.createFile(dest, filedata)
|
self.createFile(dest, filedata, binary = True)
|
||||||
|
|
||||||
return dest
|
return dest
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user