multiple S3 buckets using David Larlet's S3Storage.py
David Larlet's Amazon S3 wrapper for Django seems widely used, and I'm inclined to use it. However, there's something in the documentation that confuses me: http://code.welldev.org/django-storages/wiki/S3Storage It seems as though one can only use a single bucket, in AWS_STORAGE_BUCKET_NAME in settings.py, rather than specifying a bucket in a FileField or ImageField field definition in models.py. Our application needs to use distinct S3 buckets for different files (images, feeds, etc.). Looking at the S3Storage.py code: http://code.welldev.org/django-storages/src/af5d6b4c2d07/S3Storage.py it seems like it might be possible to specify different S3 buckets for different fields, but I'm not entirely clear on how one might do that. Any suggestions to help point me in the right direction? Thanks in advance for the excellent support here. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: multiple S3 buckets using David Larlet's S3Storage.py
Le 7 mars 09 à 05:33, wynfred a écrit : > > David Larlet's Amazon S3 wrapper for Django seems widely used, and I'm > inclined to use it. However, there's something in the documentation > that confuses me: > http://code.welldev.org/django-storages/wiki/S3Storage > > It seems as though one can only use a single bucket, in > AWS_STORAGE_BUCKET_NAME in settings.py, rather than specifying a > bucket in a FileField or ImageField field definition in models.py. > > Our application needs to use distinct S3 buckets for different files > (images, feeds, etc.). Looking at the S3Storage.py code: > http://code.welldev.org/django-storages/src/af5d6b4c2d07/S3Storage.py > > it seems like it might be possible to specify different S3 buckets for > different fields, but I'm not entirely clear on how one might do that. > > Any suggestions to help point me in the right direction? You're right, it's possible but you must import directly your storage and do not rely on django.core.files.storages.default_storage in this case. This way you can initialize directly your storage with your bucket name and pass the storage to the right field. Untested pseudo- code: s3storage = S3Storage(bucket="your-bucket-name", etc) class YourModel: yourimage = ImageField(storage=s3storage, etc) Hope it helps, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: multiple S3 buckets using David Larlet's S3Storage.py
Thank you for this helpful input, David. Have not been able to focus on this development task yet, but will soon. Your guidance is very much appreciated. Thanks, Stephen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---