Re: libcurl SFTP file upload
Date: Sat, 5 Apr 2008 09:12:06 -0700
On Sat, Apr 05, 2008 at 10:44:46AM +0200, Mueller, Alexander wrote:
> This looks for me rather like a command-line call ... I use the C-API and search for a way to do the SFTP Upload with this.
> I tried this call (see code below) as quoted command, but also got errors.
I was trying to show with that command that quote commands are not involved
in uploads. You can use the --libcurl command-line option to turn that
command line into a C program if you want.
> I really appreciate your help, but this document didn't clear the scheme for me. When using WinSCP, I can access our host (treuehandy.de) via SFTP, and there I descend down to a subfolder "treuehandy.de" and then to folder "csv", this is the structure how it should work. I tried using the "~" symbol as proposed by Daniel, but this seems to symbolize a "user home directory", it didn't work, ans in WinSCP this was also not necessary so I wonder if this leads to success.
Does WinSCP use SFTP URLs? If not, then that URL spec isn't relevant. I
don't know what WinSCP does, but what you describe is likely represented
by a URL of either sftp://treuehandy.de/treuehandy.de/csv/file-to-upload or
> I have read the documentation of "curl_easy_setopt(CURLOPT_PREQOUTE / CURLOPT_QOUTE / CURLOPT_POSTQUOTE)" several times, but I still don't get it running. My code example (see below) ran with POSTQUOTE, like in the official FTP upload example. When I run it with "CURLOPT_QOUTE" I get the described infinite loop.
> What irritates me most: I cannot find out the "PUT" command. The documentation of curl_easy_setopt(CURLOPT_QOUTE) says: "The valid SFTP commands are: chgrp, chmod, chown, ln, mkdir, pwd, rename, rm, rmdir, symlink. (SFTP support added in 7.16.3)". But these are all no upload commands ! So I tried the documented SFTP-Upload command, "put", with the described infinite loop. So what is the upload command ? The one from Dan (see above) also doesn't work, I tried it in my code which follows.
This is the fourth time someone has written this: you can't do uploads with
quote commands! So, please, please, stop trying!
> So, here comes the full code as my experimental state is at this moment (only user name was x-ed out):
> curl_easy_setopt(hCurl, CURLOPT_URL, "sftp://treuehandy.de/treuehandy.de/csv/");
URL stands for Uniform Resource Locator and the resource this URL is
pointing to is a directory; you can't upload directories. Since you're
uploading a file, you need a URL that locates a file, such as
sftp://treuehandy.de/treuehandy.de/csv/the-file Try using that and
eliminating any mention of QUOTE commands.
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2008-04-05