diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 35c8f13ed29f3f4dd2d5a11b87a44b3a569b1765..6ef11edf191a263b9b6257a5291a8f57a087bd97 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -36,6 +36,7 @@ napi_ref ImageSourceNapi::sConstructor_ = nullptr; std::shared_ptr ImageSourceNapi::sImgSrc_ = nullptr; std::shared_ptr ImageSourceNapi::sIncPixelMap_ = nullptr; static const std::string CLASS_NAME = "ImageSource"; +std::string ImageSourceNapi::filePath_ = ""; struct ImageSourceAsyncContext { napi_env env; @@ -432,6 +433,7 @@ napi_value ImageSourceNapi::CreateImageSource(napi_env env, napi_callback_info i asyncContext->pathName = buffer; HiLog::Debug(LABEL, "pathName is [%{public}s]", asyncContext->pathName.c_str()); + filePath_ = asyncContext->pathName; imageSource = ImageSource::CreateImageSource(asyncContext->pathName, opts, errorCode); } else if (argCount == NUM_1 && ImageNapiUtils::getType(env, argValue[NUM_0]) == napi_number) { napi_get_value_int32(env, argValue[NUM_0], &asyncContext->fdIndex); @@ -834,6 +836,7 @@ static std::unique_ptr UnwrapContextForModify(napi_env napi_create_reference(env, argValue[argCount - 1], refCount, &context->callbackRef); } } + context->pathName = ImageSourceNapi::filePath_; return context; } diff --git a/interfaces/kits/js/common/include/image_source_napi.h b/interfaces/kits/js/common/include/image_source_napi.h index fe3248f322be0eccf4958150e25887f55e34bae1..7c02fe4a40f37d92fb06d35f0f31c12f10a476d2 100644 --- a/interfaces/kits/js/common/include/image_source_napi.h +++ b/interfaces/kits/js/common/include/image_source_napi.h @@ -37,6 +37,8 @@ public: { return navIncPixelMap_; } + + static std::string filePath_; private: static napi_value Constructor(napi_env env, napi_callback_info info); static void Destructor(napi_env env, void *nativeObject, void *finalize);