- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我未能成功地将文件上传到 FTP 服务器,并出现错误“curl_easy_perform() failed: failed FTP upload (the STOR command)”。我用 google 搜索了很多,但找不到任何解决方案或建议。这是我的小代码
#define LOCAL_FILE "D:/er.txt"
#define REMOTE_URL "ftp://ftp.nso.edu/incoming/"
using namespace std;
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
curl_off_t nread;
size_t retcode = fread(ptr, size, nmemb, (FILE*)stream);
nread = (curl_off_t)retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
}
int main()
{
CURL *curl;
CURLcode res;
FILE *hd_src;
struct stat file_info;
curl_off_t fsize;
struct curl_slist *headerlist=NULL;
/* get the file size of the local file */
if(stat(LOCAL_FILE, &file_info)) {
printf("Couldnt open '%s': %s\n", LOCAL_FILE, strerror(errno));
return 1;
}
fsize = (curl_off_t)file_info.st_size;
printf("Local file size: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", fsize);
/* get a FILE * of the same file */
hd_src = fopen(LOCAL_FILE, "rb");
/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* we want to use our own read function */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* enable uploading */
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
curl_easy_setopt(curl,CURLOPT_URL, REMOTE_URL);
/* pass in that last of FTP commands to run after the transfer */
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
/* now specify which file to upload */
curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
/* Set the size of the file to upload (optional). If you give a *_LARGE
option you MUST make sure that the type of the passed-in argument is a
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
make sure that to pass in a type 'long' argument. */
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)fsize);
/* Now run off and do what you've been told! */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* clean up the FTP commands list */
curl_slist_free_all (headerlist);
/* always cleanup */
curl_easy_cleanup(curl);
}
fclose(hd_src); /* close the local file */
curl_global_cleanup();
// Wait for keystroke
getch();
return 0;
}
最佳答案
设置
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, char* allocatedMemoryForErrorBuffer);
字符指针将包含有关正在发生的错误的更多详细信息。通常,这适用于 HTTP 请求,但我的理解是它也应该适用于 FTP。
关于c++ - curl_easy_perform() 失败 : failed FTP upload (the STOR command) error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18268673/
我使用以下代码片段从远程 REST API 获取 43182 个字符长的 JSON: string result_; curl_easy_setopt(curlGET_, CURLOPT_TIMEOU
背景 我有 VS2015 C++ 项目,在所有 Windows >= XP 中运行,使用 libcurl处理客户请求。 问题 根据经验,服务器响应花费的时间太长,我的进程被阻塞了。 我想知道 curl
有没有一种方法可以取消 C++ 中的 curl_easy_perform?? 我有一个场景,我试图连接到离线的网络资源,curl_easy_perform 需要一定的时间才能返回 CURLE_COUL
如何隐藏 curl_easy_perform 输出(在 shell 中)? 这是关于 C 应用程序的。 最佳答案 在 curl_easy_setopt() 中使用 CURLOPT_NOBODY。示例:
我有以下问题:如何在 char * 缓冲区中写入通过 http-response 返回的数据?我发现了几种方法: 使用 CURLOPT_WRITEDATA 或 CURLOPT_WRITEFUNCTIO
我正在使用 curl 发送 POST 和 GET 请求,我使用回调函数从这些请求中获取回复。这些 callback 函数是静态成员函数,它们依次调用非静态成员函数(您不能在 curl 中直接使用非静态
使用带有 libcurl 库的 Qt5,我尝试从我的本地 FTP 服务器下载一个目录列表。如果我将所有 curl_easy_setopt() 和 curl_easy_perform() 保留在 mai
当我尝试对无法访问的服务器执行一些 HTTP_POST、HTTP_DELETE 操作时,返回代码有时为 -1。因为我的应用程序正在崩溃。 这是我的示例代码。 我的应用程序代码是用 C++ 编写的,我也
c使用libcurl curl_easy_perform post,空格和点替换为下划线 代码如下例所示。 另一边接收到的数据是错误的: 预期:data to send... 实际上:data_to_
详细的,我注意到输出: 第一次运行结束时: * Connection #0 to host www.example.com left intact 在第二次运行开始时: * Found bundle
当我在我的 c 程序中使用 curl_easy_perform 时,它以某种方式停止了我用于检查其他内容的计时器。 这是我的代码: curl_easy_setopt(curl, CURLOPT_URL
我在 libcurl 源代码树中找不到这个重要功能的源代码。我也没有在 curl.h 中找到此函数的定义。对 linux 内核 github 源代码的搜索和多个谷歌搜索都没有产生任何结果。 curl_
我写了这个简单的代码来检查网络连接或我们的 iOS 应用程序: int CL_Network::checkConnectionInt1(){ CURL *curl; CURLcode res;
我在使用 libcurl 时遇到了一些奇怪的问题 - 它拒绝解析特定的 URL,返回错误消息“无法解析主机名”。解决其他主机没有问题。我怀疑原因是失败的 URL 返回了 302 重定向,但我已经设置了
所以我在 C++ 中使用 libcurl 来检索页面中的数据,但由于某种原因,当我连接到我的 vps 时,它会在帖子标题中抛出错误。 vps 中的代码只是发出一个获取请求并从我的数据库中吐出一些数据。
我在尝试使用 libcurl 下载文件时遇到问题。该程序使用多个线程,每个需要下载文件的线程都会创建一个 libcurl 句柄来处理。 当 URL 正确时,一切正常,但如果 URL 中有错误,程序就会
对不起我的英语不好。我正在尝试运行以下代码,但是当进度运行大约一天或几个小时时它会崩溃,所以这次崩溃是偶然出现的。顺便说一句,SecMonitor_Curl 是一个单一的类,因此 curl_globa
我正在尝试使用 libcurl C++ 发出 REST/HTTP 请求。我注意到 curl_easy_perform block ,但如果我设置 CURLOPT_READFUNCTION 它不会。我只
我在我的 C++ 应用程序中使用 libcurl 7.26.0 通过 https 协议(protocol)与服务器通信。它工作正常,但在大约 20 分钟后连接失败:curl_easy_perform
在我为网站负载测试而编写的 HTTP flooder 中使用 libCURL 时,我遇到了段错误。 这里是相关代码:https://gist.github.com/AppleDash/a26e0ce0
我是一名优秀的程序员,十分优秀!