4๐
I got it I should have been using HttpResponse to return JSON data.
def sign_s3(request):
S3_BUCKET = settings.AWS_STORAGE_BUCKET_NAME
file_name = request.GET.get('file_name')
file_type = request.GET.get('file_type')
s3 = boto3.client('s3')
presigned_post = s3.generate_presigned_post(
Bucket = S3_BUCKET,
Key = file_name,
Fields = {"acl": "public-read", "Content-Type": file_type},
Conditions = [
{'acl': "public-read"},
{"Content-Type": file_type}
],
ExpiresIn = 3600
)
data = json.dumps({
'data': presigned_post,
'url': 'https://%s.s3.amazonaws.com/%s' % (S3_BUCKET, file_name),
})
return HttpResponse(data, content_type='json')
๐คTom Myers
Source:stackexchange.com