From d73050cafc3021d82f2d33f644d1fa74948a3ce4 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Fri, 22 Nov 2024 22:14:04 -0500 Subject: [PATCH] fix image uploading --- bin/up.tcl | 5 +---- lib/atpagent.tcl | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/bin/up.tcl b/bin/up.tcl index 1dacd16..033ac78 100755 --- a/bin/up.tcl +++ b/bin/up.tcl @@ -48,11 +48,8 @@ if {$conf(avatar) != {}} { set fd [open $conf(avatar) r] fconfigure $fd -translation binary - set avatar [read $fd] - close $fd - unset fd - lassign [agent xrpc com.atproto.repo.uploadBlob -type $mime $avatar] av_ncode av_data + lassign [agent xrpc com.atproto.repo.uploadBlob -type $mime -chan $fd] av_ncode av_data puts "upload: $av_data" if {$av_ncode != 200} { return -code error "got $av_ncode uploading avatar!\n$av_data" } diff --git a/lib/atpagent.tcl b/lib/atpagent.tcl index d0d1f0b..0e573d9 100644 --- a/lib/atpagent.tcl +++ b/lib/atpagent.tcl @@ -53,15 +53,25 @@ proc atpagent_inner {statename cmd argv} { set rest [lassign $rest _ mime] } - if {[llength $rest] > 1 && $mime == "application/json"} { - set rest [::json::write object {*}$rest] - } + if {[lindex $rest 0] == "-chan"} { + lassign $rest _ chan + + set http_state [http::geturl \ + [dict get $state service]/xrpc/$endpoint \ + -headers $headers \ + -querychannel $chan \ + -type $mime] + } else { + if {[llength $rest] > 1 && $mime == "application/json"} { + set rest [::json::write object {*}$rest] + } - set http_state [http::geturl \ - [dict get $state service]/xrpc/$endpoint \ - -headers $headers \ - -query $rest \ - -type $mime] + set http_state [http::geturl \ + [dict get $state service]/xrpc/$endpoint \ + -headers $headers \ + -query $rest \ + -type $mime] + } set ncode [::http::ncode $http_state] set data [::json::json2dict [::http::data $http_state]] -- 2.45.2