Plume-org / Plume

Federated blogging application, thanks to ActivityPub (now on https://git.joinplu.me/ — this is just a mirror)
https://joinplu.me
GNU Affero General Public License v3.0
2.11k stars 133 forks source link

Upload media don't work #191

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello,

I added a photo, and copied the markdown code but it's inaccessible.

The photo is stored in plume/media but the markdown link ( leads to plume/static/media, a directory that does not exist.

capture du 2018-09-03 20-37-08 capture du 2018-09-03 20-37-25 screenshot-2018-9-3 details du media plume

elegaanz commented 6 years ago

It is normal that the link points to a directory that doesn't exist: Plume does the redirection. Do you have HTTPS on your instance? Can you access the image by copying the link in the URL box of your browser?

ghost commented 6 years ago

Yes, and everything is redirected to https

No, it's make a 404 error

elegaanz commented 6 years ago

Can you tell me what this SQL command gives you?

SELECT * from medias;
ghost commented 6 years ago

screenshot-2018-9-3 selectionner medias - 127 0 0 1 - adminer

elegaanz commented 6 years ago

Thanks… I don't understand… Could you restart Plume with the RUST_BACKTRACE=1 variable set, try to load the image, and give me what gets logged please?

ghost commented 6 years ago

Upload an image:

GET /medias/new text/html:
    => Matched: GET /medias/new (new)
    => Outcome: Success
    => Response succeeded.
GET /static/main.css text/css:
    => Matched: GET /static/<file..> [2] (static_files)
    => Outcome: Success
    => Response succeeded.
GET /static/fontawesome-5.0.10/css/fontawesome-all.min.css text/css:
    => Matched: GET /static/<file..> [2] (static_files)
    => Outcome: Success
    => Response succeeded.
GET /static/fonts/Route159/Route159.css text/css:
    => Matched: GET /static/<file..> [2] (static_files)
GET /static/fonts/Lora/Lora.css text/css:
GET /static/fonts/Playfair_Display/PlayfairDisplay.css text/css:
    => Matched: GET /static/<file..> [2] (static_files)
    => Outcome: Success
    => Outcome: Success
    => Response succeeded.
    => Response succeeded.
    => Matched: GET /static/<file..> [2] (static_files)
    => Outcome: Success
    => Response succeeded.
GET /api/v1/instance:
    => Error: No matching routes for GET /api/v1/instance.
    => Warning: Responding with 404 Not Found catcher.
    => Response succeeded.
GET /api/v1/instance:
    => Error: No matching routes for GET /api/v1/instance.
    => Warning: Responding with 404 Not Found catcher.
    => Response succeeded.
POST /medias/new multipart/form-data; boundary=---------------------------135744684215428534571122881140:
    => Matched: POST /medias/new (upload)
Multipart::with_boundary(_, "---------------------------135744684215428534571122881140")
ok
    => Outcome: Success
    => Response succeeded.
GET /medias/4 text/html:
    => Matched: GET /medias/<id> (details)
    => Outcome: Success
    => Response succeeded.

Nothing appears when I try to load the image.

But when I want to delete an image:

    => Matched: GET /medias/<id>/delete (delete)
thread '<unnamed>' panicked at 'Couldn't delete media from disk: Os { code: 2, kind: NotFound, message: "Aucun fichier ou dossier de ce type" }', libcore/result.rs:945:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:463
   5: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:350
   6: rust_begin_unwind
             at libstd/panicking.rs:328
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::expect
             at /checkout/src/libcore/result.rs:809
  10: plume_models::medias::Media::delete
             at plume-models/src/medias.rs:75
  11: plume::routes::medias::delete
             at src/routes/medias.rs:103
  12: plume::routes::medias::rocket_route_fn_delete
             at src/routes/medias.rs:100
  13: rocket::rocket::Rocket::route
             at /home/maxime/.cargo/git/checkouts/rocket-8bf16d9ca7e90bdc/df71111/core/lib/src/rocket.rs:285
  14: rocket::rocket::Rocket::route_and_process
             at /home/maxime/.cargo/git/checkouts/rocket-8bf16d9ca7e90bdc/df71111/core/lib/src/rocket.rs:234
  15: rocket::rocket::Rocket::dispatch
             at /home/maxime/.cargo/git/checkouts/rocket-8bf16d9ca7e90bdc/df71111/core/lib/src/rocket.rs:213
  16: <rocket::rocket::Rocket as hyper::server::Handler>::handle
             at /home/maxime/.cargo/git/checkouts/rocket-8bf16d9ca7e90bdc/df71111/core/lib/src/rocket.rs:78
  17: <hyper::server::Worker<H>>::keep_alive_loop
             at /home/maxime/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.13/src/server/mod.rs:337
  18: <hyper::server::Worker<H>>::handle_connection
             at /home/maxime/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.13/src/server/mod.rs:283
  19: hyper::server::handle::{{closure}}
             at /home/maxime/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.13/src/server/mod.rs:242
  20: hyper::server::listener::spawn_with::{{closure}}
             at /home/maxime/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.10.13/src/server/listener.rs:50
elegaanz commented 6 years ago

I'm seeing that the 404 page is generated by Nginx. Are you using the config from the documentation, or did you modified it? And what gives ls -al media?

ghost commented 6 years ago

I'm using config from documentation

On plume?

ls -al media
total 1200
drwxrwxr-x  2 maxime maxime    4096 sept.  3 22:48 .
drwxrwxr-x 14 maxime maxime    4096 sept.  3 20:12 ..
-rw-rw-r--  1 maxime maxime 1218763 sept.  3 22:48 7B8B1863-904C-69F2-5AFF-5BC36B46DE94.jpg

on Plume/static

ls -al media
total 84
drwxrwxr-x 2 maxime maxime  4096 sept.  3 21:14 .
drwxrwxr-x 7 maxime maxime  4096 sept.  3 20:35 ..
-rw-r--r-- 1 maxime maxime  6930 sept.  3 21:13 743A7173-2C6F-AF7D-1867-D366D35385B9.jpg
-rw-r--r-- 1 maxime maxime 68648 sept.  3 20:36 BC1A55B0-BF5B-1F8E-B0DD-141F5C3F2C48.png
elegaanz commented 6 years ago

It is not normal that these media are present in Plume/static, they should all be in Plume/media. Actually Plume/static/media shouldn't even be there… From which directory did you started Plume? What if you move the two files in Plume/static/media to Plume/media?

ghost commented 6 years ago

they are in Plume/static/medias because I move these from Plume/medias Url in media manager refers to plume/static/medias/randomfile.png

When I move these files in Plume/media, there is a 404 error

ghost commented 6 years ago

i'v got clue with nginx : `2018/09/03 23:33:32 [error] 30663#30663: *11 open() "/etc/nginx/html/static/media/BC1A55B0-BF5B-1F8E-B0DD-141F5C3F2C48.png" failed (2: No such file or directory), client: 192.168.1.3, server: blog.unanargeek.xyz, request: "GET /static/media/BC1A55B0-BF5B-1F8E-B0DD-141F5C3F2C48.png HTTP/2.0", host: "blog.unanargeek.xyz", referrer: "https://blog.unanargeek.xyz/static/media/BC1A55B0-BF5B-1F8E-B0DD-141F5C3F2C48.png)"

And I've a solution: https://github.com/Plume-org/Plume/pull/193 `