- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 s3 来存储用户的上传文件,我使用 django 存储
pip install django-storages
INSTALLED_APPS = (
...
'storages',
)
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = '#################'
AWS_SECRET_ACCESS_KEY = '#######################'
AWS_STORAGE_BUCKET_NAME = 'mybucketname'
sudo pip install boto
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
Requirement already satisfied (use --upgrade to upgrade): boto in /Library/Python/2.7/site-packages/boto-2.9.0_dev-py2.7.egg
Cleaning up...
Could not load Boto's S3 bindings.
最佳答案
创建一个 bash 脚本:install_latest_boto.sh:
#install latest boto from source
cd /home/ubuntu/
sudo mkdir boto_temp
cd boto_temp
sudo git clone git://github.com/boto/boto.git
cd boto
sudo python setup.py install
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_S3_FILE_OVERWRITE = False
class MyBaseModel(models.Model):
class Meta:
abstract = True
@staticmethod
def get_upload_path(instance, filename):
if hasattr(instance, 'get_upload_folder'):
return os.path.join(instance.get_upload_folder(), filename)
else:
raise Exception('Upload Folder is missing')
class User(MyBaseModel):
name = models.CharField(max_length=100)
email = models.EmailField(max_length=255, unique=True)
image = models.ImageField(upload_to=MyBaseModel.get_upload_path, default=None, blank=True, max_length=200)
def get_upload_folder(self):
upload_folder = 'users/images/orig'
return upload_folder
关于django - 无法加载 Boto 的 S3 绑定(bind)。 (安装博托),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16148100/
[上下文:java 8,spring boot 1.5.1] 我们正在创建一个 RESTful 服务,我们需要能够上传大文件。我想要的是一个看起来像这样的 api @RequestLine("POST
我是一名优秀的程序员,十分优秀!