2012-01-18 35 views
1

所以每文檔和其他來源我嘗試Ruby curb postfield.file失敗?

捲曲:: PostField.file( 'FNAME',「路徑到文件)

結果:捲曲:ERR :invalidpostfielderror。無法將非內容字段轉換爲字符串

我錯過了什麼? File.exists(路徑到文件是真實的

+0

能否請你解釋正是你想做什麼 –

+0

試圖發送?一個通過curb http post的文件 – yodafan86

回答

0

下面是使用路邊上傳大拉鍊的一個例子:

c = Curl::Easy.new(url) 
    c.headers["Authorization"] = "Bearer #{token}" 
    c.multipart_form_post = true 
    c.on_failure { 
     # something 
    } 
    c.on_success { |data|  
     #something 
    } 
    c.http_post(Curl::PostField.content('id', my_id), 
       Curl::PostField.file('zip', "path/to/my.zip"))