Handle relative file path

tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent ffac9f3632
commit 7ee62e253d
  1. 1
      README.md
  2. 1
      patrix.spec
  3. 4
      scripts/patrix

@ -8,6 +8,7 @@ It requires the following perl modules
* File::HomeDir
* File::Basename
* File::MimeInfo
* File::Spec
* Path::Tiny
* Getopt::Long
* URI::Escape

@ -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)

@ -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,10 +242,11 @@ 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_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 }));

Loading…
Cancel
Save