~aleteoryx/tclfeed-bsky

d73050cafc3021d82f2d33f644d1fa74948a3ce4 — Aleteoryx 29 days ago 791e2e2
fix image uploading
2 files changed, 19 insertions(+), 12 deletions(-)

M bin/up.tcl
M lib/atpagent.tcl
M bin/up.tcl => bin/up.tcl +1 -4
@@ 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" }


M lib/atpagent.tcl => lib/atpagent.tcl +18 -8
@@ 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]]