To upload to a bucket, I needed a semi-permanent file path (not the tmp path created by the Uploader).
With this semi-permanent link, I create a unique name with its SHA256 and shorten it.
So instead of computing a base64 string, I serve the image from its bucket location. This has the advantage of removing several Mb from the socket memory.
I could alternatively let Phoenix serve. I just have to erase this "semi"-permanent file on the next upload instead of erasing it once I get the remote path.
Lastly, you may notice I modified the "config.exs" because when I save a file into the "priv/static/uploads" folder, then the filewatch will reload the page. I don't want this (I miserably fought with this point).
Note that I will also need a local temporary "indexes.bin" and a temporary ".wav" later so I believe this change is valid.
Before going any further, let me know if you agree with this.
If you agree, I will then:
1) add Postgres (2 tables, User and Image). The User can be omitted since there is no authentication for the moment. I will save the uploads in it
2) add tests
I created an S3 bucket named "dwyl-imgia" under my profil, but you may want to use a bucket owned by Dwyl.
The only env vars are:
To upload to a bucket, I needed a semi-permanent file path (not the tmp path created by the Uploader). With this semi-permanent link, I create a unique name with its SHA256 and shorten it. So instead of computing a base64 string, I serve the image from its bucket location. This has the advantage of removing several Mb from the socket memory. I could alternatively let Phoenix serve. I just have to erase this "semi"-permanent file on the next upload instead of erasing it once I get the remote path.
Lastly, you may notice I modified the "config.exs" because when I save a file into the "priv/static/uploads" folder, then the filewatch will reload the page. I don't want this (I miserably fought with this point).
Note that I will also need a local temporary "indexes.bin" and a temporary ".wav" later so I believe this change is valid.
Before going any further, let me know if you agree with this.
If you agree, I will then: 1) add Postgres (2 tables, User and Image). The User can be omitted since there is no authentication for the moment. I will save the uploads in it 2) add tests
I created an S3 bucket named "dwyl-imgia" under my profil, but you may want to use a bucket owned by Dwyl. The only env vars are: