+struct ChunkData
+{
+ std::vector< uint8_t > data;
+};
+
+size_t ChunkLoader(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+ std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>( userdata );
+ int numBytes = size*nmemb;
+ chunks->push_back( ChunkData() );
+ ChunkData& chunkData = (*chunks)[chunks->size()-1];
+ chunkData.data.reserve( numBytes );
+ memcpy( &chunkData.data[0], ptr, numBytes );
+ return numBytes;
+}
+
+
+CURLcode DownloadFileDataWithSize( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize )
+{
+ CURLcode result( CURLE_OK );
+
+ // create
+ Dali::Internal::Platform::FileWriter fileWriter( dataBuffer, dataSize );
+ FILE* dataBufferFilePointer = fileWriter.GetFile();
+ if( NULL != dataBufferFilePointer )
+ {
+ // we only want the body which contains the file data
+ curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
+ curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+
+ // disable the write callback, and get curl to write directly into our data buffer
+ curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, NULL );
+ curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer );
+
+ // synchronous request of the body data
+ result = curl_easy_perform( curlHandle );
+ }
+ return result;
+}
+
+CURLcode DownloadFileDataByChunk( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize )
+{
+ // create
+ std::vector< ChunkData > chunks;
+
+ // we only want the body which contains the file data
+ curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
+ curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+
+ // Enable the write callback.
+ curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader );
+ curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, &chunks );
+
+ // synchronous request of the body data
+ CURLcode result = curl_easy_perform( curlHandle );