berts-4865

berts-4865

DigitalOcean Spaces - Browser Upload with Presigned URL - CORS

Here is a quick guide to uploading a file from the browser to DO spaces.
It is crude, but will hopefully save sometime time and frustration.

I was getting an errors such as “SignatureDoesNotMatch” from DO, when it was a CORS issue.
Specifically, I think the CORS headers where not setup correctly.
They should be restricted again once your initial tests are working.

** Elixir Config**

config :ex_aws,
debug_requests: true,
json_codec: Jason,
access_key_id: “redacted”,
secret_access_key: “redacted”

config :ex_aws, :s3,
scheme: “https://”,
host: “nyc3.digitaloceanspaces.com”,
region: “nyc3”

** Elixir Function Snippet - Generate Presigned Url**

{:ok, presigned_url} = ExAws.Config.new(:s3) |> S3.presigned_url(:put, “redacted_bucket_name”, “somefile.zip”, expires_in: 3600)

** DigitalOcean Spaces - Advances CORS Configuration**

Screenshot - FuseBase

Origin: *
Methods: Tick all boxes
Allowed Headers: Allow all headers be setting the Header Name to *
Age: 0

** Frontend Uploads **

I’m using Uppy and the S3 plugin. AWS S3 | Uppy
But I won’t go into detail here on that.

There is some additional info at ExAws with DigitalOcean Spaces · Elixir
But it does not deal with CORS issues.

Where Next?

Popular in Guides/Tuts Top

dennisreimann
I wrote a guide for implementing Passwordless Authentication a.k.a. “Magic Login Links”: https://dennisreimann.de/articles/phoenix-passw...
New
Logan
Here is an example of a Mix application that utilizes Cowboy to handle websocket connections. If anyone has an idea about making this wor...
New
dkuku
I Created a blog post about setting up svelte with phoenix. I found it a bit tricky and the only blog post I found was written using som...
New
lukertty
Install web-mode and mmm-mode first and put this in your config file: (require 'mmm-mode) (require 'web-mode) (setq mmm-global-mode 'may...
New
annad
I’m posting this for developers who are totally new to Phoenix like myself. This is all probably obvious to more skilled Phoenix develope...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
sergio
Wrote this guide on how to integrate DropzoneJS with Phoenix Liveview. Hope it helps someone out! Woah read that title again, what a ...
New

Other popular topics Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement