Reputation: 799
I'm trying to set up an s3 bucket so my Django app can upload and grab user media files. I've come to the part in this video https://www.youtube.com/watch?v=kt3ZtW9MXhw&t=224s where you set the cors policy.
In this tutorial he uses XML but aws now wants json. I don't know what to put. I want my website to be able to GET, PUT, POST, PATCH and DELETE.
My app is a Django app hosted on a Digital Ocean droplet
Edit: I've found an example which I've edited and added to my config
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT",
"POST",
"DELETE"
],
"AllowedOrigins": [
"http://www.example1.com"
],
"ExposeHeaders": []
},
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT",
"POST",
"DELETE"
],
"AllowedOrigins": [
"http://www.example2.com"
],
"ExposeHeaders": []
},
{
"AllowedHeaders": [],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
Upvotes: 1
Views: 1784
Reputation: 11604
For configuring cors:-
public access to bucket.
( through bucket policy and
console) https://stackoverflow.com/a/4709391/13126651 ( for public access bucket policy)[
{
"AllowedHeaders": [
"Authorization"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"<url of first bucket with http://...without slash at the end>"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
Upvotes: 1