libcurl + multiform-data


  • Hi, I've tried to upload file using libcurl like here (original):

    local easy = curl.easy()
    :setopt_url(urls.URLS.file.scan)
    :setopt_httppost(curl.form()
    :add_content('apikey', apiKey, 'text/plain')
    :add_file('file', filePath, 'application/octet-stream',
    fname, {'Content-length: ' .. fsize}
    ))
    :perform()
    :close()

    I've tried to modify it, but with no success...

    local etr = curl.easy('https://testsite.test')
    local frm = curl.form()
    frm:add('contenttype', 'multipart/form-data')
    frm:add('file', file)
    etr:set('formpost', frm)
    etr:perform()
    etr:close()

    Is there any samples for libcurl?
    Thanks!


  • 2
    Posts
    617
    Views
    Log in to reply


  • I still get "nil Out of memory cdata<enum 568>: 27" when I try ro etr:perform()....

            local etr = curl.easy('http://xxx')
            local frm = curl.form()
            frm:add('copyname', fname, 'file', filePath, 'contenttype', 'application/octet-stream', 'contentheader', {'apikey: ' .. apikey })
    
            etr:set('httppost', frm:get())
            print(etr:perform())

2
Posts
617
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!