curl-library
[HTTP][POST] file upload speed is too low.
Date: Fri, 18 Jan 2013 14:42:30 +0900
Hello everyone..
Now i'm try to upload the big size file(about 85MB) from embedded system to
cloud via HTTP Post.
but upload speed is too low as below:
- avg. speed during 10 times : 750000 bytes/sec during 115 seconds
Actually i expected that avg. speed is over 10~15 Mbps.
Is my code not optimized??
How can i make a improvement for upload speed.
Thank you in advanced.
My code is as below:
size_t read_data (char *bufptr, size_t size, size_t nitems, FILE *userp)
{
size_t read;
read = fread(bufptr, size, nitems, userp);
//read = READ(userp, bufptr, size);
return read;
}
int upload()
{
FILE *fd;
struct stat file_info;
fd = fopen(gFullPathForUpload, "rb");
if(fd == NULL)
{
logprintf((char *)"HTTP_request - FD is NULL");
return ret; /* can't continue */
}
// to get the file size
if(fstat(fileno(fd), &file_info) != 0)
{
logprintf((char *)"HTTP_request - can't check the fstat");
return ret; /* can't continue */
}
// tell it to "upload" to the URL
curl_easy_setopt(ctx, CURLOPT_UPLOAD, 1L);
// set the function for file read
curl_easy_setopt(ctx, CURLOPT_READFUNCTION, read_data);
// set where to read from
curl_easy_setopt(ctx, CURLOPT_READDATA, fd);
// and give the size of the upload (optional)
curl_easy_setopt(ctx, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
curl_easy_setopt(ctx, CURLOPT_CUSTOMREQUEST, "POST");
responseHeaders = curl_slist_append( responseHeaders , "Content-Type:
application/octet-stream" ) ;
responseHeaders = curl_slist_append( responseHeaders , "Accept:
application/json" ) ;
curl_easy_setopt( ctx , CURLOPT_HTTPHEADER , responseHeaders ) ;
curl_easy_setopt(ctx, CURLOPT_COOKIEFILE, "");
curl_easy_setopt( ctx , CURLOPT_URL, "
https://upload.mycloud.com/restapi/file?gFilenameForUpload" ) ;
curl_easy_setopt( ctx , CURLOPT_NOPROGRESS , TRUE ) ;
curl_easy_setopt( ctx , CURLOPT_WRITEDATA , &response_data ) ;
curl_easy_setopt(ctx, CURLOPT_WRITEFUNCTION, cb_writefunction );
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYPEER, FALSE);
CURLcode rc = curl_easy_perform( ctx ) ;
curl_slist_free_all( responseHeaders );
curl_easy_cleanup( ctx ) ;
curl_global_cleanup() ;
}
P.s.) Please understand me even if my word is very poor. English is not my
mother tongue. :-)
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-01-18