cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

SFTP delete file with space

From: Anders Havn <anders.havn_at_gmail.com>
Date: Thu, 17 May 2012 15:24:25 +0200

Hi,

I have a problem when deleting/renaming/chmod a file if the file or
the file path includes a space:
Ex: "sftp://myftpserver.org/UserFolder/Test xyz.txt" <-- space in filename
Ex: "sftp://myftpserver.org/User Folder/Test.txt" <-- space in filepath

It works fine if the path have no spaces:
Ex: "sftp://myftpserver.org/UserFolder/Test.txt"

This is how my codes looks:

NSString username = @"username";
NSString password = @"password";
NSString* fullFilePath = @"sftp://myftpserver.org/UserFolder/Test xyz.txt"

NSString* filePath = @"rm /UserFolder/Test xyz.txt"
 struct curl_slist* headerlist = curl_slist_append(NULL, [filePath
cStringUsingEncoding:encoding]);

curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, [fullFilePath
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_USERNAME, [username
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_PASSWORD, [password
cStringUsingEncoding:encoding]);
curl_easy_setopt(curl, CURLOPT_VERBOSE, (long)1);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerList);
CURLcode result = curl_easy_perform(curl);
curl_slist_free_all (headerList);
curl_easy_cleanup(curl);

Just want to repeat again that the code works fine when there are no
spaces involved in the filename or the full file path.

Thank you for you help.

Best Regards,
Anders Havn
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-17

These mail archives are generated by hypermail.

donate! Page updated January 05, 2012.
web site info

File upload with ASP.NET