plone / guillotina-volto

Other
1 stars 1 forks source link

Cannot download uploaded files from Volto #2

Open frapell opened 3 years ago

frapell commented 3 years ago

I have been trying to figure this one out and I am failing... Here is what I am doing Starting a PostgreSQL

docker run --rm -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_INITDB_ARGS=--data-checksums -e POSTGRES_DB=guillotina -p 5432:5432 -it postgres:9.6

I have a checkout of this repo, with everything installed and starting it like this

$ ./bin/g -c config.yaml 
No sender mail configured on mailer.default_sender settings
You are using a very insecure secret key in production mode. It is strongly advised that you provide a better value for `jwt.secret` in your config.
INFO:     Started server process [283151]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8081 (Press CTRL+C to quit)

For the first time I run ./bin/initdb which created the initial structure

INFO:     127.0.0.1:38808 - "GET /db HTTP/1.1" 200 OK
INFO:     127.0.0.1:38812 - "POST /db/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:38822 - "POST /db/web/%40addons HTTP/1.1" 200 OK
INFO:     127.0.0.1:38826 - "POST /db/web/%40addons HTTP/1.1" 200 OK
INFO:     127.0.0.1:38830 - "POST /db/web/groups HTTP/1.1" 201 Created
INFO:     127.0.0.1:38834 - "POST /db/web/users HTTP/1.1" 201 Created
INFO:     127.0.0.1:38838 - "GET /db/web HTTP/1.1" 200 OK
INFO:     127.0.0.1:38842 - "POST /db/web/%40workflow/publish HTTP/1.1" 200 OK
INFO:     127.0.0.1:38846 - "GET /db/web/%40user HTTP/1.1" 200 OK
INFO:     127.0.0.1:38850 - "GET /db/web/ HTTP/1.1" 200 OK

Finally, I have a Volto checkout and I am starting it with

$ RAZZLE_API_PATH=http://localhost:8081/db/web RAZZLE_DEV_PROXY_API_PATH=http://localhost:8081/db/web yarn start
yarn run v1.22.10
$ razzle start
 WAIT  Compiling...

✔ Client
  Compiled successfully in 365.08ms

✔ Server
  Compiled successfully in 2.51s

✅  Server-side HMR Enabled!
API server (API_PATH) is set to: http://localhost:8081/db/web
Using internal proxy: http://localhost:3000 -> http://localhost:8081/db/web
🎭 Volto started at http://localhost:3000 🚀

I visit http://localhost:3000/ in my browser and I get the initial site. I login to it, and create a File item. I get all the fields in the add form, I choose a PDF as file, give it a title and save.

image

So far so good, however, when I click the actual file to download it, I don't get it...

The file item exists at http://localhost:3000/test-file and the generated link is http://localhost:3000/test-file/@download/file/document.pdf but when issuing a request to it, instead of getting the file, I get a 200 returned, and volto tries to show a page for it, which issues a bunch of other requests, that are invalid

INFO:     127.0.0.1:44244 - "GET /db/web/test-file/%40download/file/document.pdf/%40breadcrumbs HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44248 - "GET /db/web/test-file/%40download/file/document.pdf/%40navigation?expand.navigation.depth=1 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44250 - "GET /db/web/test-file/%40download/file/document.pdf/%40types HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44252 - "GET /db/web/test-file/%40download/file/document.pdf/%40workflow HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44246 - "GET /db/web/test-file/%40download/file/document.pdf HTTP/1.1" 200 OK
INFO:     127.0.0.1:44272 - "GET /db/web/test-file/%40download/file/document.pdf/%40navigation?expand.navigation.depth=1 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44276 - "GET /db/web/test-file/%40download/file/document.pdf/%40breadcrumbs HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44280 - "GET /db/web/test-file/%40download/file/document.pdf/%40actions HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44272 - "GET /db/web/test-file/%40download/file/document.pdf HTTP/1.1" 200 OK
INFO:     127.0.0.1:44280 - "GET /db/web/test-file/%40download/file/document.pdf/%40actions HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:44276 - "GET /db/web/test-file/%40download/file/document.pdf/%40types HTTP/1.1" 404 Not Found

Now, if I simply use curl to reach guillotina directly to that URL, I can get the file just fine

$ curl -i -X GET http://localhost:8081/db/web/test-file/@download/file/document.pdf --output testfile.pdf --user root:root
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2330k  100 2330k    0     0  39.9M      0 --:--:-- --:--:-- --:--:-- 39.9M

I've been trying to debug the whole execution until the response is returned, and everything appears correct, here are the headers...

$ curl -I -X GET http://localhost:8081/db/web/test-file/@download/file/document.pdf  --user root:root
HTTP/1.1 200 OK
date: Tue, 18 May 2021 23:51:55 GMT
server: uvicorn
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Content-Disposition: attachment; filename="document.pdf"
Accept-Ranges: bytes
Content-Type: application/pdf
Content-Length: 2386085

I suspect the broken piece here is Volto, but it does work fine with Plone as backend... So not sure what am I missing...

frapell commented 3 years ago

@bloodbare Have you seen this issue? do you maybe have some suggestions on what might be broken? maybe it is too obvious but I am missing it...