I have a django web service. I want to be able to accept images from an iOS app, save the image to the database(the image file itself should be belt in my s3 bucket).
It's super easy saving it through the admin, you just define the upload_to
and set the bucket as the static_url, but I can not find any examples/documentaion on how to save an image sent from an app for example.
Can anyone point me in the right direction or give an example?
A bit more information as my question is vague:
class Image(models.Model):
name = models.CharField(max_length = 255)
caption = models.CharField(max_length = 255)
image = models.ImageField(upload_to='uploads/',blank=True,null=True)
rent_property = models.ForeignKey(RentProperty, related_name='Images')
is_main_image = models.BooleanField(default=False)
setting.py
#Amazon Bucket
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = '################'
AWS_SECRET_ACCESS_KEY = '#####################'
AWS_STORAGE_BUCKET_NAME = 'string'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
this is my image class, what Im trying to do, is to get an image from the app, save it to to the database and the S3 storage, and link it to the correct foreign key.
My trouble is in understand how I make the file save to the S3 while saving the information to the database.