readonly
readonly

Reputation: 355474

How do you upload a file with rest-client and specify the filename?

I tried the following to upload a file with RestClient, but the resulting POST always uses the file's filename ("testfile.txt") instead of "file_name.txt":

RestClient::Resource.new(path, resource_options).post(:transfer => { :path => "file_name.txt" }, :upload => File.new('/tmp/testfile.txt', 'rb'))

Upvotes: 2

Views: 1414

Answers (2)

Archiloque
Archiloque

Reputation: 11

If you want to specify a different name you can override the original_filename method of the File object you use

And you can use a String as payload, just pass your string

If you have other questions, you're welcome to ask them on the rest-client mailing list referenced on the project homepage

Upvotes: 1

Christian
Christian

Reputation: 28125

Did you try switching them and see what happens?

Upvotes: 0

Related Questions