{"record":{"id":"dc3bff65642032dd","repo":"Yalantis/uCrop","slug":"cimg-load-network-loading-files-from-network-i","errorCode":null,"errorMessage":"cimg::load_network(): Loading files from network is disabled.","messagePattern":"cimg::load_network\\(\\): Loading files from network is disabled\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":70065,"sourceCode":"    /**\n       \\param url URL of the filename, as a C-string.\n       \\param[out] filename_local C-string containing the path to a local copy of \\c filename.\n       \\param timeout Maximum time (in seconds) authorized for downloading the file from the URL.\n       \\param try_fallback When using libcurl, tells using system calls as fallbacks in case of libcurl failure.\n       \\param referer Referer used, as a C-string.\n       \\param user_agent User agent used, as a C-string.\n       \\return Value of \\c filename_local.\n       \\note Use the \\c libcurl library, or the external binaries \\c wget or \\c curl to perform the download.\n    **/\n    inline char *load_network(const char *const url, char *const filename_local,\n                              const unsigned int timeout, const bool try_fallback,\n                              const char *const referer, const char *const user_agent) {\n      if (!url)\n        throw CImgArgumentException(\"cimg::load_network(): Specified URL is (null).\");\n      if (!filename_local)\n        throw CImgArgumentException(\"cimg::load_network(): Specified destination string is (null).\");\n      if (!network_mode())\n        throw CImgIOException(\"cimg::load_network(): Loading files from network is disabled.\");\n\n      const char *const __ext = cimg::split_filename(url), *const _ext = (*__ext && __ext>url)?__ext - 1:__ext;\n      CImg<char> ext = CImg<char>::string(_ext);\n      *filename_local = 0;\n      if (ext._width>16 || !cimg::strncasecmp(ext,\"cgi\",3)) *ext = 0;\n      else cimg::strwindows_reserved(ext);\n      do {\n        cimg_snprintf(filename_local,256,\"%s%c%s%s\",\n                      cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext._data);\n      } while (cimg::path_exists(filename_local));\n\n#ifdef cimg_use_curl\n      const unsigned int omode = cimg::exception_mode();\n      cimg::exception_mode(0);\n      try {\n        CURL *curl = 0;\n        CURLcode res;\n        curl = curl_easy_init();","sourceCodeStart":70047,"sourceCodeEnd":70083,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L70047-L70083","documentation":"cimg::load_network() refuses to run when cimg::network_mode() returns false, throwing this CImgIOException. Network loading is a compile/runtime-configurable capability of CImg; when disabled (built with cimg_use_no_network or runtime-disabled), any attempt to download a file is rejected up front rather than silently failing.","triggerScenarios":"Calling load_network() (or CImg<T>::load_network / load on a http:// URL) while the CImg library was compiled with network support disabled, or network_mode() was turned off at runtime.","commonSituations":"Bundling CImg in an Android/iOS NDK build (like uCrop) without enabling libcurl-based network support; desktop builds with cimg_display/cimg network flags off; apps that deliberately disable network file loading for sandboxing.","solutions":["Enable network support in the CImg build configuration (link libcurl and remove cimg_use_no_network / define network mode on) if downloads are needed.","If network loading is intentionally disabled, download the file yourself (via your HTTP client) to a local path and load that local file with CImg instead.","Avoid http(s):// URLs in load paths when the build has no network support.","Catch CImgIOException around load_network and fall back to bundled/local assets."],"exampleFix":"// before\nimg.load_network(remoteUrl, localPath); // throws: network disabled\n// after\nstd::string local = downloadWithAppHttpClient(remoteUrl); // app's own HTTP layer\nimg.load(local.c_str());","handlingStrategy":"fallback","validationCode":"if (!cimg::network_mode()) {\n  std::string local = downloadWithAppHttpClient(remoteUrl);\n  img.load(local.c_str());\n} else {\n  img.load_network(remoteUrl, local, 30, true, 0, 0);\n}","typeGuard":null,"tryCatchPattern":"try { img.load_network(url, local, 30, true, 0, 0); } catch (const CImgIOException &e) { /* network disabled: use bundled asset */ img.load(\"assets/default.png\"); }","preventionTips":["Know whether your CImg build has network support enabled before using http:// URLs","In sandboxed/mobile builds, do your downloads with the app's own HTTP layer and load local files","Document the cimg network build flags in your project so builds don't silently disable features","Provide bundled fallback assets for any remote resource"],"tags":["network","configuration","disabled-feature","cimg"],"backgroundTag":"feature-not-enabled","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}