dwyl / image-classifier

🖼️ Classify images and extract data from or describe their contents using machine learning
GNU General Public License v2.0
20 stars 3 forks source link

1. added upload to S3 #27

Closed ndrean closed 10 months ago

ndrean commented 10 months ago

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:

#source .env
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
LuchoTurtle commented 10 months ago

Refer to #28 for this feature (for anyone reading) :)

ndrean commented 10 months ago

Ok, perfect, yes. And no pb! Just let me know if you want something!