views:

26

answers:

2

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'))
A: 

Did you try switching them and see what happens?

Christian Sciberras
It always uses the name of the file that it opens...alternatively, is there a way to specify the payload in a string instead of requiring that a file be opened?
Readonly
"is there a way to specify the payload in a string instead of requiring that a file be opened?"Depends on whether you want to upload a file or not?
Christian Sciberras
A: 

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

Archiloque