---
title: File
description: Read/write files on the device.
---
<!--
# 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
# under the License.
-->
# cordova-plugin-file
[![Android Testsuite](https://github.com/apache/cordova-plugin-file/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-file/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-file/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-file/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-file/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-file/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-file/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-file/actions/workflows/lint.yml)
This plugin implements a File API allowing read/write access to files residing on the device.
This plugin is based on several specs, including :
The HTML5 File API
[http://www.w3.org/TR/FileAPI/](http://www.w3.org/TR/FileAPI/)
The Directories and System extensions
Latest:
[http://www.w3.org/TR/2012/WD-file-system-api-20120417/](http://www.w3.org/TR/2012/WD-file-system-api-20120417/)
Although most of the plugin code was written when an earlier spec was current:
[http://www.w3.org/TR/2011/WD-file-system-api-20110419/](http://www.w3.org/TR/2011/WD-file-system-api-20110419/)
It also implements the FileWriter spec :
[http://dev.w3.org/2009/dap/file-system/file-writer.html](http://dev.w3.org/2009/dap/file-system/file-writer.html)
>*Note* While the W3C FileSystem spec is deprecated for web browsers, the FileSystem APIs are supported in Cordova applications with this plugin for the platforms listed in the _Supported Platforms_ list, with the exception of the Browser platform.
To get a few ideas how to use the plugin, check out the [sample](#sample) at the bottom of this page. For additional examples (browser focused), see the HTML5 Rocks' [FileSystem article.](http://www.html5rocks.com/en/tutorials/file/filesystem/)
For an overview of other storage options, refer to Cordova's
[storage guide](http://cordova.apache.org/docs/en/latest/cordova/storage/storage.html).
This plugin defines a global `cordova.file` object.
Although the object is in the global scope, it is not available to applications until after the `deviceready` event fires.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(cordova.file);
}
## Installation
cordova plugin add cordova-plugin-file
## Supported Platforms
- Android
- iOS
- OS X
- Windows*
- Browser
\* _These platforms do not support `FileReader.readAsArrayBuffer` nor `FileWriter.write(blob)`._
## Where to Store Files
As of v1.2.0, URLs to important file-system directories are provided.
Each URL is in the form _file:///path/to/spot/_, and can be converted to a
`DirectoryEntry` using `window.resolveLocalFileSystemURL()`.
* `cordova.file.applicationDirectory` - Read-only directory where the application
is installed. (_iOS_, _Android_, _BlackBerry 10_, _OSX_, _windows_)
* `cordova.file.applicationStorageDirectory` - Root directory of the application's
sandbox; on iOS & windows this location is read-only (but specific subdirectories [like
`/Documents` on iOS or `/localState` on windows] are read-write). All data contained within
is private to the app. (_iOS_, _Android_, _BlackBerry 10_, _OSX_)
* `cordova.file.dataDirectory` - Persistent and private data storage within the
application's sandbox using internal memory (on Android, if you need to use
external memory, use `.externalDataDirectory`). On iOS, this directory is not
synced with iCloud (use `.syncedDataDirectory`). (_iOS_, _Android_, _BlackBerry 10_, _windows_)
* `cordova.file.cacheDirectory` - Directory for cached data files or any files
that your app can re-create easily. The OS may delete these files when the device
runs low on storage, nevertheless, apps should not rely on the OS to delete files
in here. (_iOS_, _Android_, _BlackBerry 10_, _OSX_, _windows_)
* `cordova.file.externalApplicationStorageDirectory` - Application space on
external storage. (_Android_)
* `cordova.file.externalDataDirectory` - Where to put app-specific data files on
external storage. (_Android_)
* `cordova.file.externalCacheDirectory` - Application cache on external storage.
(_Android_)
* `cordova.file.externalRootDirectory` - External storage (SD card) root. (_Android_, _BlackBerry 10_)
* `cordova.file.tempDirectory` - Temp directory that the OS can clear at will. Do not
rely on the OS to clear this directory; your app should always remove files as
applicable. (_iOS_, _OSX_, _windows_)
* `cordova.file.syncedDataDirectory` - Holds app-specific files that should be synced
(e.g. to iCloud). (_iOS_, _windows_)
* `cordova.file.documentsDirectory` - Files private to the app, but that are meaningful
to other application (e.g. Office files). Note that for _OSX_ this is the user's `~/Documents` directory. (_iOS_, _OSX_)
* `cordova.file.sharedDirectory` - Files globally available to all applications (_BlackBerry 10_)
## File System Layouts
Although technically an implementation detail, it can be very useful to know how
the `cordova.file.*` properties map to physical paths on a real device.
### iOS File System Layout
| Device Path | `cordova.file.*` | `iosExtraFileSystems` | r/w? | persistent? | OS clears | sync | private |
|:-----------------------------------------------|:----------------------------|:----------------------|:----:|:-----------:|:---------:|:----:|:-------:|
| `/var/mobile/Applications/<UUID>/` | applicationStorageDirectory | - | r | N/A | N/A | N/A | Yes |
| `appname.app/` | applicationDirectory | bundle | r | N/A | N/A | N/A | Yes |
| `www/` | - | - | r | N/A | N/A | N/A | Yes |
| `Documents/` | documentsDirectory | documents | r/w | Yes | No | Yes | Yes |
| `NoCloud/` | - | documents-nosync | r/w | Yes | No | No | Yes |
| `Library` | - | library | r/w | Yes | No | Yes? | Yes |
| `NoCloud/` | dataDirectory | library-nosync | r/w | Yes | No | No | Yes |
| `Cloud/` | syncedDataDirectory | - | r/w | Yes | No | Yes | Yes |
| &nb
没有合适的资源?快使用搜索试试~ 我知道了~
gcV0.9902.zip
共2000个文件
png:1295个
md:733个
js:314个
需积分: 0 0 下载量 134 浏览量
2023-05-07
15:07:16
上传
评论
收藏 345.14MB ZIP 举报
温馨提示
gcV0.9902.zip
资源推荐
资源详情
资源评论
收起资源包目录
gcV0.9902.zip (2000个子文件)
FileSystem.api 694B
comp.atlas 51KB
comp.atlas 51KB
comp.atlas 11KB
colorBlock_shadow.atlas 887B
colorBlock_shadow.atlas 887B
colorBlock.atlas 712B
colorBlock.atlas 712B
temp.atlas 186B
snapshot_blob.bin 1.49MB
v8_context_snapshot.bin 162KB
v8_context_snapshot.bin 162KB
natives_blob.bin 89KB
canvasbuilder.cfg 129B
json_value.cpp 40KB
json_reader.cpp 21KB
json_writer.cpp 21KB
plugin.cpp 8KB
tokenizer.cpp 6KB
toast_js.cpp 4KB
Logger.cpp 3KB
toast_ndk.cpp 2KB
.cproject 68KB
Toast.cs 6KB
Vibration.cs 2KB
AssemblyInfo.cs 2KB
Insomnia.cs 636B
Vibration.csproj 3KB
chunk-vendors.6f5f0eae.css 284KB
gcAsset.css 155KB
editor.main.css 116KB
app.9ee4a32e.css 41KB
app.0db35212.css 41KB
app.a97cd569.css 41KB
amWiki.css 32KB
amWiki.css 32KB
markdownbody.github.css 10KB
markdownbody.github.css 10KB
lhjs.github-gist.css 990B
lhjs.github-gist.css 990B
kdsrpgIDE-plug.css 172B
a_rectangle_mouse_cur.cur 4KB
a_rubber_mouse_cur.cur 4KB
a_selection_precinct_mouse_cur.cur 4KB
a_Paint_bucket_mouse_cur.cur 4KB
a_rectangle_mouse_cur.cur 4KB
a_rubber_mouse_cur.cur 4KB
a_selection_precinct_mouse_cur.cur 4KB
a_Paint_bucket_mouse_cur.cur 4KB
icudtl.dat 9.93MB
icudtl.dat 9.93MB
nw.dll 155.46MB
nw.dll 153.86MB
node.dll 12.79MB
node.dll 12.79MB
libGLESv2.dll 6.53MB
libGLESv2.dll 6.53MB
d3dcompiler_47.dll 4.31MB
d3dcompiler_47.dll 4.31MB
vk_swiftshader.dll 3.84MB
ffmpeg.dll 2.78MB
ffmpeg.dll 2.78MB
libGLESv2.dll 2.6MB
libGLESv2.dll 2.6MB
msvcr120d.dll 1.74MB
nw_elf.dll 950KB
nw_elf.dll 949KB
msvcp120d.dll 796KB
vulkan-1.dll 789KB
libEGL.dll 412KB
libEGL.dll 412KB
libEGL.dll 395KB
libEGL.dll 395KB
nwjc.exe 23.56MB
chromedriver.exe 11.46MB
run.exe 2.09MB
GameCreator.exe 2.09MB
notification_helper.exe 969KB
notification_helper.exe 969KB
payload.exe 827KB
GameCreatorBin.gamecreator 7KB
GameCreatorBin.gamecreator 7KB
gclife.gcdata 120B
.gitignore 16B
build-extras.gradle 2KB
value.h 34KB
CDVFile.h 7KB
reader.h 7KB
CDVFile.h 6KB
writer.h 6KB
json_batchallocator.h 4KB
plugin.h 3KB
tokenizer.h 2KB
config.h 2KB
Toast+UIView.h 1KB
features.h 1KB
CDVOrientation.h 1KB
CDVLocalFilesystem.h 1KB
CDVLocalFilesystem.h 1KB
CDVAssetLibraryFilesystem.h 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
2301_78019334
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (完整)数据库课程设计餐厅点餐说明书-21ab6d3c8beb172ded630b1c59eef8c75ebf952c.doc
- 2023-04-06-项目笔记 - 第一百五十四阶段 - 4.4.2.152全局变量的作用域-152 -2024.06.04
- 松哥解协议松哥解协议松哥解协议松哥解协议松哥解协议
- 618节日618节日618节日
- tensorflow-gpu-2.9.1-cp37-cp37m-win-amd64.whl
- tensorflow-gpu-2.9.0-cp37-cp37m-win-amd64.whl
- tensorflow-gpu-2.9.0-cp39-cp39-win-amd64.whl
- lcd daimalcd daima
- 电影领域-推荐算法-个性化内容-观影决策-电影推荐小程序.zip
- 电气控制PLC考试题库
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功