diff --git a/README.md b/README.md index 57ab7c7..1ceceda 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ It requires the following perl modules * File::HomeDir * File::Basename * File::MimeInfo + * File::Spec * Path::Tiny * Getopt::Long * URI::Escape diff --git a/patrix.spec b/patrix.spec index 862ab15..07905c0 100644 --- a/patrix.spec +++ b/patrix.spec @@ -18,6 +18,7 @@ Requires: perl(Getopt::Long) Requires: perl(JSON) Requires: perl(File::Basename) Requires: perl(File::MimeInfo) +Requires: perl(File::Spec) Requires: perl(Path::Tiny) Requires: perl(URI::Escape) Requires: perl(Term::ReadKey) diff --git a/scripts/patrix b/scripts/patrix index a5be894..2f0f2b3 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -10,6 +10,7 @@ use Config::Simple; use File::HomeDir; use File::MimeInfo; use File::Basename; +use File::Spec; use URI::Escape; use Path::Tiny; use Term::ReadKey; @@ -241,11 +242,12 @@ sub send_file { # Sending a file is a 2 steps operation. First we need to upload the file to the media store # And then we post the uri on the room debug("Uploading file $opt->{file} to the media store"); + $opt->{file} = File::Spec->rel2abs($opt->{file}); my $uri = $opt->{server} . '/_matrix/media/v1/upload?access_token=' . $opt->{access_token} . '&filename=' . basename($opt->{file}); my $resp = send_request({ uri => $uri, - content_type => mimetype $opt->{file}, - content => path( $opt->{file} )->slurp_raw + content_type => mimetype($opt->{file}), + content => path($opt->{file})->slurp_raw }); debug("File upload response is\n" . to_json(from_json($resp->decoded_content), { pretty => 1 })); die "Error uploading file\n" unless ($resp->is_success);