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'))
readonly
  • 343,444
  • 107
  • 203
  • 205

2 Answers2

1

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
  • 11
  • 1
0

Did you try switching them and see what happens?

Christian
  • 27,509
  • 17
  • 111
  • 155
  • 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 Jul 11 '10 at 19:38
  • "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 Jul 11 '10 at 19:51