diff options
author | Matias Linares <matiaslina@gmail.com> | 2020-05-17 20:09:38 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@gmail.com> | 2020-05-17 20:09:38 -0300 |
commit | 4823babb29e8d2c2f65b775e72210aac7a2175c5 (patch) | |
tree | 7433d7c5c662e4ebea5b55349a1e34632bcc8030 /lib/Matrix/Client.pm6 | |
parent | ba413134ddcc6177b3673ba18d0035d78714e3fe (diff) | |
download | perl6-matrix-client-4823babb29e8d2c2f65b775e72210aac7a2175c5.tar.gz |
Add Matrix::Client::MediaStore class
This is to wrap all the endpoints pointing to the media store.
Diffstat (limited to 'lib/Matrix/Client.pm6')
-rw-r--r-- | lib/Matrix/Client.pm6 | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Matrix/Client.pm6 b/lib/Matrix/Client.pm6 index 9022c65..2e26ee7 100644 --- a/lib/Matrix/Client.pm6 +++ b/lib/Matrix/Client.pm6 @@ -5,6 +5,7 @@ use Matrix::Response; use Matrix::Client::Common; use Matrix::Client::Room; use Matrix::Client::Requester; +use Matrix::Client::MediaStore; unit class Matrix::Client does Matrix::Client::Requester; @@ -331,16 +332,15 @@ method remove-room-alias($room-alias) { # Media -#| POST - /_matrix/media/r0/upload -method upload(IO::Path $path, Str $filename?) { - my $buf = slurp $path, :bin; - my $fn = $filename ?? $filename !! $path.basename; - my $res = $.post-bin("/upload", $buf, - content-type => "image/png", - filename => $fn, - ); - my $data = from-json($res.content); - $data<content_uri> // ""; +method media(--> Matrix::Client::MediaStore) { + return Matrix::Client::MediaStore.new( + home-server => $!home-server, + access-token => $!access-token + ) +} + +method upload(IO::Path $path, Str $filename?) is DEPRECATED('media.upload') { + self.media.upload($path, $filename) } # Misc |