Skip to content

Commit

Permalink
simple files
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Jan 11, 2025
1 parent d7ba323 commit 0b7870d
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions app/apis/wechat/base_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ def initialize(app)
)
end

def post_file(path, file, params: {}, headers: {}, origin: nil, debug: nil, **options)
with_options = { origin: origin }
with_options.merge! debug: STDERR, debug_level: 2 if debug

with_access_token(params) do |with_token_params|
form_file = file.is_a?(HTTP::FormData::File) ? file : HTTP::FormData::File.new(file, content_type: options[:content_type])
response = @client.plugin(:multipart).with_headers(headers).with(with_options).post(
path,
params: with_token_params,
form: { media: form_file }
)

debug ? response : parse_response(response)
end
end

protected
def with_access_token(params: {}, headers: {}, tries: 2)
app.refresh_access_token unless app.access_token_valid?
Expand Down

0 comments on commit 0b7870d

Please sign in to comment.