Git Product home page Git Product logo

django-qiniu-storage's People

Contributors

callsamleung avatar duoduo369 avatar glasslion avatar soloradish avatar zhaozhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-qiniu-storage's Issues

base_path获取问题

测试环境:WIN10 X64 Python3.6.2
setting如下

STATIC_ROOT = os.path.join(BASE_DIR, 'collectstatic')
……
DEFAULT_FILE_STORAGE = 'qiniustorage.backends.QiniuStorage'
STATICFILES_STORAGE = 'qiniustorage.backends.QiniuStaticStorage'

报错如下

  File "D:\Anaconda3\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 260, in delete_file
    if self.storage.exists(prefixed_path):
  File "D:\Anaconda3\lib\site-packages\qiniustorage\backends.py", line 154, in exists
    stats = self._file_stat(name, silent=True)
  File "D:\Anaconda3\lib\site-packages\qiniustorage\backends.py", line 145, in _file_stat
    name = self._normalize_name(self._clean_name(name))
  File "D:\Anaconda3\lib\site-packages\qiniustorage\backends.py", line 108, in _normalize_name
    name)
django.core.exceptions.SuspiciousOperation: Attempted access to 'css/bootstrap-theme.css' denied.

开调试获取到_normalize_name函数中的变量如下

base_path = 'E:\\Code\\djprj\\collectstatic'
final_path = ''css/bootstrap-theme.css''

delete方法不起作用?

我这里删除方法不能把七牛bucket的图片删除。。
发现可能是image.name出错,把url里已经有的media_root又加了一遍
把backends.Qiniustorage 的delete方法里面的:
name = self._normalize_name(self._clean_name(name))
改成
name = self._clean_name(name)
才能可以同步删除操作…
还是我错过了什么细节?

富文本编辑器的支持

作者你好,你的作品确实很棒,不过有一点问题,好像对富文本编辑器(比如djangoUeditor)的图片支持不够,无法让图片走七牛,还是我的使用有问题。希望你能尽快回复我,如果是支持不够,我最近会pull request到这里

请问下存放在static目录里面的资源和存放在media目录里面的资源,能否使用不同域名提供服务

看到demo_site里面有以下字段,感觉应该是支持再同一个BUCKET下,static和media支持不通的域名吧?

#七牛给开发者分配的 AccessKey
QINIU_ACCESS_KEY = "xxxxxxxxxxxxxxxx"
#七牛给开发者分配的 Secret
QINIU_SECRET_KEY = "xxxxxxxxxxxxx"
#用来存放文件的七牛空间(bucket)的名字
QINIU_BUCKET_NAME = "test"
#对象存储对应的域名
QINIU_BUCKET_DOMAIN = "img.xxx.info"
#是否通过 HTTPS 来访问七牛云存储上的资源(若为'是', 可填True, true 或 1;若为'否', 可填False, false 或 0) 默认为否
QINIU_SECURE_URL = False

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = '/media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = 'http://img.xxxx.info/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = '/static'

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = 'http://static.xxx.info/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '9=mp)3*)4=bf_)-rf^4&34shdwqsmtn%bh#!lw^s$1i=#c4s&@'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'demo_site.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'demo_site.wsgi.application'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'qiniustorage',
    'foo',
    'bar',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)



#存放用户上传的资源,如图片;
DEFAULT_FILE_STORAGE = 'qiniustorage.backends.QiniuMediaStorage'
#存放js,css等静态资源
STATICFILES_STORAGE = 'qiniustorage.backends.QiniuStaticStorage'

但是static这个域名好像没有生效,网站引用的还是img.xxx.info这个域名?!

怎样设置上传到文件的大小?

问题1:怎样设置上传文件的大小?比如限制上传图片最大只能2MB,怎样设置。
问题2:上传图片压缩功能,有吗,怎样使用?
谢谢

ValueError: Cannot serialize: <qiniustorage.backends.QiniuStorage object at 0x110e2a518>

file = FileField(storage=QiniuStorage())
当执行makemigration时,会失败,显示

    "topics/migrations/#migration-serializing" % (value, get_docs_version())
ValueError: Cannot serialize: <qiniustorage.backends.QiniuStorage object at 0x110e2a518>
There are some values Django cannot serialize into migration files.
For more, see https://docs.djangoproject.com/en/1.11/topics/migrations/#migration-serializing

use pc upload image time_out

qiniustorage.utils.QiniuError: status_code:-1, x_log:None, error:('Connection aborted.', timeout('timed out',)), text_body:None, _ResponseInfo__response:None, req_id:None, exception:('Connection aborted.', timeout('timed out',))

qiniu python sdk需要升级

在使用Supervisor的过程中遇到问题:
Permission denied: '/root/.qiniu_pythonsdk_hostscache.json'

经查:qiniu/python-sdk#225

七牛官方已经升级了SDK修复问题,更新下sdk应该可以解决

settings 取值异常

当QINIU_SECURE_URL 填写True 或者 False 会发生下面异常

AttributeError at /
'bool' object has no attribute 'strip'
Request Method: GET
Request URL:    http://whispering-plains-4390.herokuapp.com/
Django Version: 1.8
Exception Type: AttributeError
Exception Value:    
'bool' object has no attribute 'strip'
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/qiniustorage/backends.py in get_qiniu_config, line 33
Python Executable:  /app/.heroku/python/bin/python
Python Version: 2.7.10
Python Path:    
['/app',
 '/app/.heroku/python/bin',
 '/app/.heroku/python/lib/python2.7/site-packages/setuptools-18.1-py2.7.egg',
 '/app/.heroku/python/lib/python2.7/site-packages/pip-7.1.0-py2.7.egg',
 '/app',
 '/app/.heroku/python/lib/python27.zip',
 '/app/.heroku/python/lib/python2.7',
 '/app/.heroku/python/lib/python2.7/plat-linux2',
 '/app/.heroku/python/lib/python2.7/lib-tk',
 '/app/.heroku/python/lib/python2.7/lib-old',
 '/app/.heroku/python/lib/python2.7/lib-dynload',
 '/app/.heroku/python/lib/python2.7/site-packages']
Server time:    Fri, 18 Sep 2015 08:00:14 +0000

qiniustorage.backends.get_qiniu_config 完善应当加层判断处理

Use Qiniu together with Solr Thumbnail

If I use Qiniu Storage at the backend with packages which use solr thumbnail, then the image cannot be displayed properly.

e.g.

{% thumbnail image.original "440x400" upscale=False as thumb %}
              <img src="{{ thumb.url }}" alt="{{ product.get_title }}" />
{% endthumbnail %}

The above code will change the url to https://{$url}/media/cache/79/07/79079b0cfd2b4a867b4b7cea3d072f0b.jpg
where the image does not really exist.

Amazon S3 have solved this issue. I am thinking whether Qiniu can solve it as well.

请问下同步静态文件报这个错误是什么原因?

(base) [hongye@host172-235 hongye-wx-api]$ python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
collected = self.collect()
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
handler(path, prefixed_path, storage)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 352, in copy_file
self.storage.save(prefixed_path, source_file)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/django/core/files/storage.py", line 52, in save
return self._save(name, content)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/qiniustorage/backends.py", line 124, in _save
self._put_file(name, content_str)
File "/home/hongye/miniconda3/lib/python3.7/site-packages/qiniustorage/backends.py", line 131, in _put_file
raise QiniuError(info)
qiniustorage.utils.QiniuError: _ResponseInfo__response:None, exception:('Connection aborted.', timeout('timed out')), status_code:-1, text_body:None, req_id:None, x_log:None, error:('Connection aborted.', timeout('timed out'))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.