license: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
一個 API,用於讀取、 寫入和導航基於w3c 檔 api的檔案系統層次結構.
從 3.0 版,科爾多瓦作為外掛程式實現了設備級 Api。 使用 CLI 的 plugin 命令,描述在命令列介面,可以添加或刪除一個專案,為此功能:
$ cordova plugin add org.apache.cordova.file
$ cordova plugin ls
[ 'org.apache.cordova.file' ]
$ cordova plugin rm org.apache.cordova.file
要使用的檔案傳輸外掛程式必須單獨添加的。
$ cordova plugin add org.apache.cordova.file-transfer
$ cordova plugin ls
[ 'org.apache.cordova.file-transfer' ]
$ cordova plugin rm org.apache.cordova.file-transfer
這些命令適用于所有有針對性的平臺,但修改如下所述的特定于平臺的配置設置:
Android 系統
(in app/res/xml/config.xml)
<feature name="File">
<param name="android-package" value="org.apache.cordova.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.FileTransfer" />
</feature>
(in app/AndroidManifest.xml)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
黑莓手機 WebWorks
(in www/plugins.xml)
<feature name="File">
<param name="blackberry-package" value="org.apache.cordova.file.FileManager" />
</feature>
<feature name="FileTransfer">
<param name="blackberry-package" value="org.apache.cordova.http.FileTransfer" />
</feature>
(in www/config.xml)
<feature id="blackberry.io.file" required="true" version="1.0.0.0" />
<feature id="blackberry.utils" required="true" version="1.0.0.0" />
<feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
<rim:permissions>
<rim:permit>access_shared</rim:permit>
</rim:permissions>
(在 iOSconfig.xml)
<feature name="File">
<param name="ios-package" value="CDVFile" />
</feature>
<feature name="FileTransfer">
<param name="ios-package" value="CDVFileTransfer" />
</feature>
一些平臺可能支援此功能,而無需任何特殊的配置。請參見在概述部分中的平臺支援。