forked from nkronlage/JavaScripture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.jsdoc
More file actions
94 lines (74 loc) · 2.31 KB
/
Copy pathfile.jsdoc
File metadata and controls
94 lines (74 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
File : Blob
File is a %%/Blob|Blob%% that represents a file from the filesystem.
You can get Files from the
%%/HTMLInputElement#files|HTMLInputElement.files%% property or
the %%/DataTransferItem#getAsFile|DataTransferItem.getAsFile()%% method.
Use %%/FileReader|FileReader%% to read the contents of a File.
Spec:
http://dev.w3.org/2006/webapi/FileAPI/#dfn-file
----
new File( \
fileParts : Array, \
name : String, \
[filePropertyBag : { \
type : String /* A valid mime type such as **'text/plain'** */, \
endings = 'transparent' : String /* Must be either **'transparent'** or **'native'** */ \
}]) : File
Creates a new **File**. The elements of **fileParts** must be of the types
%%/ArrayBuffer|**ArrayBuffer**%%,
%%/ArrayBufferView|**ArrayBufferView**%%,
%%/Blob|**Blob**%%, or
%%/String|**String**%%.
If **ending** is set to **'native'**, the line endings in the file will be
converted to the system line endings, such as **'\r\n'** for Windows or **'\n'** for
Mac.
<example>
var file = new File(['foo', 'bar'], 'foobar.txt');
console.log('size=' + file.size);
console.log('type=' + file.type);
console.log('name=' + file.name);
var testEndings = function(string, endings) {
var file = new File([string], { type: 'plain/text',
endings: endings });
var reader = new FileReader();
reader.onload = function(event){
console.log(endings + ' of ' + JSON.stringify(string) +
' => ' + JSON.stringify(reader.result));
};
reader.readAsText(file);
};
testEndings('foo\nbar', 'native');
testEndings('foo\r\nbar', 'native');
testEndings('foo\nbar', 'transparent');
testEndings('foo\r\nbar', 'transparent');
</example>
----
instance.name : String
The name of the file.
<htmlexample>
<input type='file' onchange='onFilePicked(event)'>
<script>
var onFilePicked = function(event) {
var input = event.target;
var file = input.files[0];
console.log(file.name);
};
</script>
</htmlexample>
ReadOnly:
true
----
instance.lastModifiedDate : Date
The last time the file was modified.
<htmlexample>
<input type='file' onchange='openFile(event)'>
<script>
var openFile = function(event) {
var input = event.target;
var file = input.files[0];
console.log(file.lastModifiedDate);
};
</script>
</htmlexample>
ReadOnly:
true