Lucy-Family-Institute / presqt

Tools and RESTful Services to Improve Preservation and Re-use of Research Data & Software.
Apache License 2.0
4 stars 2 forks source link

Can't upload a file to zenodo using curl #753

Closed ptsefton closed 3 years ago

ptsefton commented 3 years ago

I am trying to use the Docker environment to do an upload to Zenodo.

I tried this:

curl -F 'presqt-file=sample/sample-crate.zip' -H "presqt-destination-token: XXXXXXXX" -H "presqt-file-duplicate-action: update" -H "Accept: application/json" http://127.0.0.1:8000/api_v1/targets/zenodo/resources/ -v

But I am getting an error asking for a presqt-source-token - which I think should not need as I am trying an upload not a transfer.

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> POST /api_v1/targets/zenodo/resources/ HTTP/1.1
> Host: 127.0.0.1:8000
> User-Agent: curl/7.64.1
> presqt-destination-token: xxxxxx
> presqt-file-duplicate-action: update
> Accept: application/json
> Content-Length: 169
> Content-Type: multipart/form-data; boundary=------------------------1e97f8c9b4f13b5c
> 
* We are completely uploaded and fine
< HTTP/1.1 400 Bad Request
< Date: Tue, 25 May 2021 03:11:52 GMT
< Server: WSGIServer/0.2 CPython/3.7.1
< Content-Type: application/json
< Allow: GET, POST, HEAD, OPTIONS
< Content-Length: 79
< Referrer-Policy: same-origin
< Vary: Origin
< 
* Connection #0 to host 127.0.0.1 left intact
{"error":"PresQT Error: 'presqt-source-token' missing in the request headers."}* Closing connection 0
branks42 commented 3 years ago

Hello Peter,

Inside your curl request you need an @ before your file path.

curl -F 'presqt-file=@sample/sample-crate.zip' -H "presqt-destination-token: XXXXXXXX" -H "presqt-file-duplicate-action: update" -H "Accept: application/json" http://127.0.0.1:8000/api_v1/targets/zenodo/resources/ -v

Also, I've updated the code to no longer require a presqt-email-opt-in in the headers. This is something specific to our servers and was never fully documented. If you just pull the latest that will all be taken care of.