Using pre-signed URL method to upload a file from the browser(javascript) to spaces account. It has been blocked
Access to XMLHttpRequest at 'https://my/signed/url' from origin 'http://192.168.1.233:8000' has been blocked by CORS policy: Response to the preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
XMLHttpRequest
var blob = new Blob([e.target.files[0]], {type: e.target.files[0].type});
var xhr = new XMLHttpRequest();
xhr.open('PUT', data.upload_url);
xhr.send(blob);
console.log(xhr.status)
Updated CORS Configurations(Host, Max Age and Allowed methods) in Spaces settings, but still the CORS header issue raises. What I'm actually missing here. The same works in python requests,
Python requests:
with open(archive_file, 'rb') as data:
response = requests.put(signed_uri, data=data)
Sending as file index from $.ajax()
is even failing. Can anyone suggest me how can I upload from javascript
without using nodejs
or react