本文整理汇总了Python中django.core.files.storage.DefaultStorage.location方法的典型用法代码示例。如果您正苦于以下问题:Python DefaultStorage.location方法的具体用法?Python DefaultStorage.location怎么用?Python DefaultStorage.location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.files.storage.DefaultStorage
的用法示例。
在下文中一共展示了DefaultStorage.location方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: value_from_datadict
# 需要导入模块: from django.core.files.storage import DefaultStorage [as 别名]
# 或者: from django.core.files.storage.DefaultStorage import location [as 别名]
def value_from_datadict(self, data, files, name):
s3_path = data.get(name, None)
if s3_path is None:
return None
mode = 'r'
storage = DefaultStorage()
storage.location = ''
name = urllib.unquote_plus(urlparse(s3_path).path.lstrip('/'))
input_file = S3BotoStorageFile(name, mode, storage)
return input_file
示例2: handle_file_upload
# 需要导入模块: from django.core.files.storage import DefaultStorage [as 别名]
# 或者: from django.core.files.storage.DefaultStorage import location [as 别名]
self.filebrowser_pre_upload.send(sender=request, path=request.POST.get('folder'), file=filedata)
uploadedfile = handle_file_upload(path, filedata, site=self)
if file_already_exists:
old_file = smart_unicode(file_name)
new_file = smart_unicode(uploadedfile)
self.storage.move(new_file, old_file, allow_overwrite=True)
self.filebrowser_post_upload.send(sender=request, path=request.POST.get('folder'), file=FileObject(smart_unicode(file_name), site=self))
# let Ajax Upload know whether we saved it or not
ret_json = {'success': True, 'filename': filedata.name}
return HttpResponse(json.dumps(ret_json))
storage = DefaultStorage()
storage.location = MEDIA_ROOT
storage.base_url = MEDIA_URL
# Default FileBrowser site
site = FileBrowserSite(name='filebrowser', storage=storage)
# Default actions
from actions import *
site.add_action(flip_horizontal)
site.add_action(flip_vertical)
site.add_action(rotate_90_clockwise)
site.add_action(rotate_90_counterclockwise)
site.add_action(rotate_180)
示例3: DefaultStorage
# 需要导入模块: from django.core.files.storage import DefaultStorage [as 别名]
# 或者: from django.core.files.storage.DefaultStorage import location [as 别名]
import os.path
from tempfile import NamedTemporaryFile
# Django imports
from django.conf import settings
from django.core.files.storage import DefaultStorage
from django.core.files import File
# PIL import
try:
from PIL import Image
except ImportError:
import Image
storage = DefaultStorage()
storage.location = settings.MEDIA_ROOT
storage.base_url = settings.MEDIA_URL
def path_strip(path, root):
if not path or not root:
return path
path = os.path.normcase(path)
root = os.path.normcase(root)
if path.startswith(root):
return path[len(root) :]
return path
def get_version_path(value, version_prefix, root):
"""