cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLE_OPERATION_TIMEDOUT when FTP upload with large files

From: A-ZYSTEMS <info_at_azystems.de>
Date: Sun, 31 May 2009 14:39:04 +0200

Hello,

I am a beginner user of libcurl under windows with wxWidget.

I have writed a function for uploading files to a ftp-Server.

When I upload a file less as 40 MB, i have no problems. When I load a bigger
file (for example 56 MB) "curl_easy_perform" return a
CURLE_OPERATION_TIMEDOUT. But the uploaded file is complete save on the
ftp-Server.

I have no idea what is wrong in my code.

   // Dateigröße ermitteln für Progressdialog
   char* p_filename = "...\File.zip"
   struct stat sb;
   if( stat( p_filename, &sb ) < 0 ) {
      return false;
   }
   

   //-----------------------------------------------------------
   CURL *curl;
   FILE * hd_src ;
   CURLcode res;

   // Filie size for CURLOPT_INFILESIZE_LARGE
   struct stat file_info;
   /* get the file size of the local file */
   int hd = _open(p_filename, O_RDONLY) ;
   fstat(hd, &file_info);
   _close(hd) ;

   /* get a FILE * of the same file, could also be made with
   fdopen() from the previous descriptor, but hey this is just
   an example! */
   hd_src = fopen(p_filename, "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)
   {
        struct curl_slist *pHeaders = NULL;
      
     /* we want to use our own read function */
      curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
      
      wxString sDestinationServer =
"ftp://test.fastwebserver.de/printer_1/incoming"
        m_strOrder = wxT("12345");

      wxFileName fn(m_strSendFile);
      char* sMkDir = CPXTConvert::wxStringToCharPtr(wxT("MKDIR "
+ m_strOrder),ISO8859_1);
      char* sAccess =
CPXTConvert::wxStringToCharPtr(wxT("pixit:pixit.921"));
      char* sftp =
CPXTConvert::wxStringToCharPtr(sDestinationServer,ISO8859_1);
      char* url =
CPXTConvert::wxStringToCharPtr(sDestinationServer + wxT("/") + m_strOrder +
wxT("/") + fn.GetFullName(),ISO8859_1);

       pHeaders = curl_slist_append( pHeaders , sMkDir) ;

      /* FTP PUT please */
      curl_easy_setopt(curl, CURLOPT_URL, sftp);

      // FTP Password
      curl_easy_setopt(curl, CURLOPT_USERPWD, sAccess);

      /* Now run off and do what you've been told! */
      res = curl_easy_perform(curl);

      /* clean up the FTP commands list */
      curl_slist_free_all (pHeaders);

      /* FTP PUT please */
      curl_easy_setopt(curl, CURLOPT_URL, url);

      // FTP Password
      curl_easy_setopt(curl, CURLOPT_USERPWD, sAccess);

      /* enable uploading */
      curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
      curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1) ;

      /* now specify which file to upload */
      curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

      /* provide the size of the upload, we specicially typecast the value
      to curl_off_t since we must be sure to use the correct data size */
      curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
         (curl_off_t)file_info.st_size);

      /* Now run off and do what you've been told! */
      res = curl_easy_perform(curl);
 

      /* always cleanup */
      curl_easy_cleanup(curl);

      delete sMkDir;
      delete url;
      delete sAccess;

   }
   fclose(hd_src); /* close the local file */
   curl_global_cleanup();
   delete p_filename;

 

Thanks for helping

Alexander
 
Received on 2009-05-31