use transfer.sh in other programming language #344

Closed
opened 2026-01-19 18:29:58 +00:00 by michael · 3 comments
Owner

Originally created by @shayanzare on GitHub.

Hello.

How can i use transfer.sh api in other programming language like ruby and c++?
have lib for this language?

Thanks.

Originally created by @shayanzare on GitHub. Hello. How can i use transfer.sh **api** in other programming language like ruby and c++? have lib for this language? Thanks.
Author
Owner

@kmkmjhyiiiu commented on GitHub:

You can use curl to transfer your file.

@kmkmjhyiiiu commented on GitHub: You can use curl to transfer your file.
Author
Owner

@mitchellurgero commented on GitHub:

Ruby, PHP, C++,C#, etc,etc all support "curl" like http clients. So uploading to transfer.sh using pretty much any language will work fine.

@mitchellurgero commented on GitHub: Ruby, PHP, C++,C#, etc,etc all support "curl" like http clients. So uploading to transfer.sh using pretty much any language will work fine.
Author
Owner

@retorquere commented on GitHub:

I'm looking to upload a text snippet I have in-code (in Ruby) that I want to upload to transfer.sh; if possible I'd like to do so directly without first writing it to disk. I currently have this:

require 'net/http/post/multipart'
require 'net/http'
require 'rest-client'
require 'curb'

# net/http with multipart
uri = URI.parse('https://transfer.sh/')
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
  req = Net::HTTP::Post::Multipart.new(uri, { "file" => "A nice picture!" })
  puts http.request(req).body.inspect
end

# net/http with put
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
  req = Net::HTTP::Put.new(uri)
  req.body = "whatever"
  puts http.request(req).body.inspect
end

# restclient
puts RestClient.post('https://transfer.sh/', {:file => 'bar', :multipart => true}).body.inspect

# curb
c = Curl::Easy.new('https://transfer.sh/')
c.multipart_form_post = true
c.http_post([ Curl::PostField.content('file', 'hello') ])
puts c.body_str.inspect

but this gets me an empty response body in all those cases. It must be something I'm doing wrong in Ruby, because this python snippet works just fine:

import requests
response = requests.post('https://transfer.sh/', files={'travis.md':'baz'})
print(response.text)
@retorquere commented on GitHub: I'm looking to upload a text snippet I have in-code (in Ruby) that I want to upload to transfer.sh; if possible I'd like to do so directly without first writing it to disk. I currently have this: ``` require 'net/http/post/multipart' require 'net/http' require 'rest-client' require 'curb' # net/http with multipart uri = URI.parse('https://transfer.sh/') Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| req = Net::HTTP::Post::Multipart.new(uri, { "file" => "A nice picture!" }) puts http.request(req).body.inspect end # net/http with put Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| req = Net::HTTP::Put.new(uri) req.body = "whatever" puts http.request(req).body.inspect end # restclient puts RestClient.post('https://transfer.sh/', {:file => 'bar', :multipart => true}).body.inspect # curb c = Curl::Easy.new('https://transfer.sh/') c.multipart_form_post = true c.http_post([ Curl::PostField.content('file', 'hello') ]) puts c.body_str.inspect ``` but this gets me an empty response body in all those cases. It must be something I'm doing wrong in Ruby, because this python snippet works just fine: ``` import requests response = requests.post('https://transfer.sh/', files={'travis.md':'baz'}) print(response.text) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#344