I have a django app on heroku which serves the static files from amazon s3 bucket. I use boto library and followed the guide on the website. What can I do to speed up the file transfers?
Some of the code:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'xxxx'
AWS_SECRET_ACCESS_KEY = 'xxxx'
AWS_STORAGE_BUCKET_NAME = 'boxitwebservicebucket'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATIC_URL = 'http://' + AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/'
the view
class GetFileContent(View):
def get(self,request, userName, pk):
user = User.objects.filter(username = userName)
filtered = Contentfile.objects.filter(pk = pk, published=True, file_owner = user)
data = filtered[0].content
filename = filtered[0].title + "." + filtered[0].file_type
response = HttpResponse(data, content_type='application/force-download')
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
return response
pass
I suspect django is serving the file even though it sits on the s3 server, How can I direct the user to the s3 link directly?