Uppy with DO Storages on Django
I can not get Uppy AWS to work. I am using DigitalOcean Storage.
Here is the HTML (part is GitHub Copilot):
<div id="uppy"></div>
<script type="module">
import {Uppy, Dashboard, AwsS3} from "https://releases.transloadit.com/uppy/v4.13.3/uppy.min.mjs"
const uppy = new Uppy()
uppy.use(Dashboard, {target: '#uppy', inline: true})
.use(AwsS3, {
getUploadParameters (file, options) {
return fetch('/upload/uppy_s3').then((response) => response.json())
},
})
</script>
Here is the backend view:
client = boto3.client('s3',
region_name='sgp1',
endpoint_url='https://sgp1.digitaloceanspaces.com',
aws_access_key_id=SPACES_KEY,
aws_secret_access_key=SPACES_SECRET,
config=Config(s3={'addressing_style': 'virtual'}),
)
url = client.generate_presigned_url(
ClientMethod='get_object',
Params={
"Bucket": "mysite-bucket",
"Key": "uppyfile.pdf",
},
ExpiresIn=3600
)
return {
"method": "PUT",
"url": url,
"headers": {
"content-type": "application/pdf"
},
}
I have tried many combinations. Right now I am getting:
AttributeError: 'dict' object has no attribute 'status_code'