0

I am trying to upload MEDIA_FILES on Amazon's S3 service. I would like to upload them at root of bucket first and then maybe create sub-folders before saving file. My test model is simple

from django.db import models

# Create your models here.


class TestModel(models.Model):
    name = models.CharField(max_length=10)
    logo = models.ImageField(upload_to='pictures/')

    class Meta:
        verbose_name = ('TestModel')
        verbose_name_plural = ('TestModels')

    def __unicode__(self):
        pass

I have a sub-folder named pictures already created.

settigns.py

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'id'
AWS_SECRET_ACCESS_KEY = 'secret_key'
AWS_STORAGE_BUCKET_NAME = 'mybucket'

from S3 import CallingFormat
AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN

But when I try to add a TestModel from the admin panel I get the following error

Request URL:    http://127.0.0.1:8000/admin/testmodel/testmodel/add/
Django Version: 1.6.4
Exception Type: TypeError
Exception Value:    
'NoneType' object has no attribute '__getitem__'

Does s3 and django-storages work just like before? What is the value of MEDIA_URL to set when using s3? What is the value of MEDIA_ROOT to set when using S3 and django-storages?

Can I use this way to upload a file to an S3 Service? It's my first time I use a cloud storage so I am a bit confused.

Apostolos
  • 7,763
  • 17
  • 80
  • 150

1 Answers1

0

if you wanna use S3, check the "boto", python module for aws , http://boto.readthedocs.org/en/latest/ and here about MEDIA_ROOT and MEDIA_URL https://docs.djangoproject.com/en/dev/ref/settings/#media-root

privaloff
  • 66
  • 4
  • I know what media root is, what I asked was how to set it up to use it with django-storages and s3. I know of both too since django-storages uses it. – Apostolos May 13 '14 at 16:08
  • My bad, not paid attention that you use django-storage, i used tinyS3 in my project. – privaloff May 14 '14 at 06:13
  • No problem I think I am getting to it using this http://stackoverflow.com/a/10825691/2349589 – Apostolos May 14 '14 at 07:08