Hi!
Can someone help me be able to upload to an ftp or even an sftp. Here
is the code I have for an sftp. However, it says:
* SSH authentication methods available: publickey,gssapi-
keyex,external-keyx,gssapi-with-mic,gssapi,password
* Using ssh public key file /home/user_name/.ssh/id_dsa.pub
* Using ssh private key file /home/user_name/.ssh/id_dsa
* SSH public key authentication failed: Unable to open public key file
* Initialized password authentication
* Authentication complete
* Upload failed: Operation failed (4/-31)
* Connection #0 to host host_url left intact
* Closing connection #0
Upload failed: Operation failed (4/-31)
Is there something wrong in my code, or is authorization failing?
#include <curlpp/curlpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
using namespace curlpp::options;
char *data = NULL;
size_t readData(char *buffer, size_t size, size_t nitems)
{
strncpy(buffer, data, size * nitems);
return size * nitems;
}
int main(int, char **)
{
try {
FILE *hd_src;
// That's all that is needed to do cleanup of used resources
(RAII style).
curlpp::Cleanup myCleanup;
// Our request to be sent.
curlpp::Easy myRequest;
// Set the URL.
hd_src = fopen("debugit", "rb"); /* open file to upload */
myRequest.setOpt<ReadFunction>(readData);
myRequest.setOpt<Upload>(1L);
myRequest.setOpt<Url>("sftp://path_to_dir/");
myRequest.setOpt<UserPwd>("username:password");
myRequest.setOpt<ReadFile>(hd_src);
myRequest.setOpt<Verbose>(1);
//myRequest.setOpt<InFileSize>((long)file_);
// Send request and get a result.
// By default the result goes to standard output.
myRequest.perform();
}
catch(curlpp::RuntimeError & e) {
std::cout << e.what() << std::endl;
}
catch(curlpp::LogicError & e) {
std::cout << e.what() << std::endl;
}
return 0;
}
Thank you very much
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"curlpp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/curlpp?hl=en
-~----------~----~----~----~------~----~------~--~---