If I am using the index method to generate a html form in browser and then select file to upload, it will generate the Plug.Upload, but if I directly post the upload file in curl will not generate the Plug.Upload at all. Any idea?
Since the curl command is good and can upload a file in one command line, I am thinking maybe I can use Elixir Plug directly to tackle the upload part. But Cowboy give error and not even reach the Plug:
$ curl -v -H "Authorization: Bearer 45ac1JvKsRNky25qnGpC28xAJGvckRXEkzq2a45" -H "Content-Type: multiform/form-data" -F "name=upload" -F "file=@music_local_cache/music.mp3" http://localhost:8080/token/token_create
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8080 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /token/token_create HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer 45ac1JvKsRNky25qnGpC28xAJGvckRXEkzq2a45
> Content-Length: 300481
> Content-Type: multiform/form-data; boundary=------------------------7bbc66155ea0c6ef
> Expect: 100-continue
>
< HTTP/1.1 415 Unsupported Media Type
< cache-control: max-age=0, private, must-revalidate
< content-length: 20
< date: Wed, 14 Oct 2020 11:23:23 GMT
< server: Cowboy
* HTTP error before end of send, stop sending
<
* Closing connection 0
Something went wrong