npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cordova-ohos/cordova-plugin-filepath

v1.6.0

Published

Cordova File Path Plugin

Readme

cordova-plugin-filepath

一个为Cordova应用提供文件路径转换能力的插件,解决移动平台下文件URL与真实文件路径之间的转换问题,支持Android、iOS和OHOS平台。

概述

在Cordova应用开发中,经常会遇到通过系统API(如文件选择器、相机)获取的文件URL格式不便于直接使用的问题。cordova-plugin-filepath插件提供了简单的API,可将这些特殊格式的文件URL转换为应用可直接访问的绝对文件路径,同时也支持将绝对路径反向转换为平台特定的URL。本文档主要说明在OHOS系统中的应用。

支持平台

  • Android:API 21及以上

  • iOS:11.0及以上

  • OHOS:5.0及以上

安装

通过Cordova CLI或Ionic CLI安装插件,支持从npm仓库或GitHub仓库安装。

基础安装(推荐)


# hcordova
npm intall -g hcordova

# Cordova CLI
hcordova plugin add cordova-plugin-filepath

从GitCode安装(开发版本)


hcordova plugin add https://github.com/OpenHarmony-Cordova/cordova-plugin-filepath.git --platform ohos

安装指定版本


hcordova plugin add [email protected] --platform ohos

卸载


# Cordova CLI
hcordova plugin remove cordova-plugin-filepath

# 指定OHOS卸载
hcordova plugin remove cordova-plugin-filepath --platform ohos

核心API

方法签名


// Promise方式
window.FilePath.resolveNativePath(url)

// 回调函数方式
window.FilePath.resolveNativePath(url, successCallback, errorCallback)

使用示例

function selectPhotoUri() {
    var cameraOptions={ quality: 25,mediaType: Camera.MediaType.PICTURE };//see cordova camera docs
    var args = {
        'selectMode': 101, //101=picker image and video , 100=image , 102=video
        'maxSelectCount': 1 //default 40 (Optional)
    };

    //选择一个图片获取uri
    MediaPicker.getMedias(args, function(medias) {
        if(medias.length > 0) {
            window.FilePath.resolveNativePath(medias[0].uri, function(filePath) {
                document.getElementById("uriPath").innerHTML = "uri:"+medias[0].uri;
                document.getElementById("filePath").innerHTML = "path:"+filePath;
            }, function(error) {
                document.getElementById("filePath").innerHTML = JSON.stringify(error);
            });
        }
    }, function(e) { console.log(e) }, cameraOptions);
}

许可证

本插件基于 Apache License 开源,详见 LICENSE 文件。

参考资源