Add DownloadRemoteFileIntoMemory function 27/221427/2
authorhuiyu.eun <huiyu.eun@samsung.com>
Mon, 23 Dec 2019 01:13:32 +0000 (10:13 +0900)
committerhuiyu eun <huiyu.eun@samsung.com>
Wed, 29 Jan 2020 08:17:45 +0000 (08:17 +0000)
Change-Id: I9ba7ab59e2633e2c6a2584f5498c4cbf39a50938
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
dali/devel-api/adaptor-framework/file-loader.cpp
dali/devel-api/adaptor-framework/file-loader.h
dali/internal/adaptor-framework/generic/file-loader-impl-generic.cpp

index b63b5c7..c567456 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/internal/adaptor-framework/common/file-loader-impl.h>
+#include <dali/internal/imaging/common/file-download.h>
 
 namespace Dali
 {
 
+namespace
+{
+
+// limit maximum image down load size to 50 MB
+const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE  = 50 * 1024 * 1024 ;
+
+}
+
 namespace FileLoader
 {
 
@@ -45,6 +54,12 @@ std::streampos GetFileSize(const std::string& filename)
   return Dali::Internal::Adaptor::GetFileSize(filename);
 }
 
+bool DownloadFileSynchronously(const std::string& filename, Dali::Vector<uint8_t> &dataBuffer)
+{
+  size_t dataSize;
+  return TizenPlatform::Network::DownloadRemoteFileIntoMemory( filename, dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE );
+}
+
 } //FileLoader
 
 } //Dali
index 7b158a9..a658952 100644 (file)
@@ -70,6 +70,17 @@ DALI_ADAPTOR_API int ReadFile(const std::string& filename, std::streampos& fileS
  * @return the size of the file or 0 if file not found
  */
 DALI_ADAPTOR_API std::streampos GetFileSize(const std::string& filename);
+
+
+/**
+ * @brief Download a requested file into a memory buffer.
+ *
+ * @param[in] filename  Filename of the file to download.
+ * @param[out] dataBuffer  A memory buffer object to be written with downloaded file data.
+ * @return error code. false - Error, true - Ok
+ */
+DALI_ADAPTOR_API bool DownloadFileSynchronously(const std::string& filename, Dali::Vector<uint8_t> &dataBuffer);
+
 };
 
 } // Dali
index 45422e7..0d5d190 100644 (file)
@@ -73,7 +73,7 @@ int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector
   }
   else
   {
-    DALI_LOG_WARNING( "file open failed for: \"%s\"", filename );
+    DALI_LOG_WARNING( "file open failed for: \"%s\"", filename.c_str() );
   }
 
   return errorCode;