/
File.cljs
260 lines (176 loc) · 6.9 KB
/
File.cljs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
(ns web.files.File
"The File interface provides information about files and allows
in a web page to access their content."
(:refer-clojure :exclude [name type]))
(def constructor
"Constructor.
The File() constructor creates a new `web.files.File` object instance.
bits
An `js.Array` of `js.ArrayBuffer`, `web.typed.ArrayBufferView`, `web.files.Blob`, or `web.dom.DOMString` objects — or a mix of any such objects. This is the file content encoded as UTF-8.
name
A `web.USVString` representing the file name or the path to the file.
options Optional
An options object containing optional attributes for the file. Available options are as follows:
type: A `web.dom.DOMString` representing the MIME type of the content that will be put into the file. Defaults to a value of \\\"\\\".
lastModified: A number representing the number of milliseconds between the Unix time epoch and when the file was last modified. Defaults to a value of `Date.now()`.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/File`"
js/File)
(defn slice
"Method.
The Blob.slice() method is used to create a new `web.files.Blob`
containing the data in the specified range of bytes of the source
`var blob = instanceOfBlob.slice([start [, end [, contentType]]]);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice`"
[this & args]
(apply (-> this .-slice) (concat [this] args)))
(defn get-as-binary
"Method.
The getAsBinary method allows to access the file's data in raw
format.
`var binary = instanceOfFile.getAsBinary();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/getAsBinary`"
[this ]
(-> this (.getAsBinary)))
(defn get-as-data-url
"Method.
The getAsDataURL provides a `data:` URL that encodes the entire
of the referenced file.
`var url = instanceOfFile.getAsDataURL();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/getAsDataURL`"
[this ]
(-> this (.getAsDataURL)))
(defn get-as-text
"Method.
The getAsText method provides the file's data interpreted as
using a given encoding.
`var str = instanceOfFile.getAsText(encoding);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/getAsText`"
[this encoding]
(-> this (.getAsText encoding)))
(defn last-modified
"Property.
The File.lastModified read-only property provides the last modified
of the file as the number of milliseconds since the Unix epoch
1, 1970 at midnight). Files without a known last modified date
the current date.
`const time = instanceOfFile.lastModified;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified`"
[this]
(-> this (.lastModified)))
(defn set-last-modified!
"Property.
The File.lastModified read-only property provides the last modified
of the file as the number of milliseconds since the Unix epoch
1, 1970 at midnight). Files without a known last modified date
the current date.
`const time = instanceOfFile.lastModified;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/lastModified`"
[this val]
(aset this "lastModified" val))
(defn size
"Property.
Returns the size of a file in bytes.
`var size = instanceOfFile.size`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/size`"
[this]
(-> this (.size)))
(defn set-size!
"Property.
Returns the size of a file in bytes.
`var size = instanceOfFile.size`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/size`"
[this val]
(aset this "size" val))
(defn file-name
"Property.
Returns the name of the file. For security reasons the path is
from this property.
`var name = instanceOfFile.fileName;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/fileName`"
[this]
(-> this (.fileName)))
(defn set-file-name!
"Property.
Returns the name of the file. For security reasons the path is
from this property.
`var name = instanceOfFile.fileName;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/fileName`"
[this val]
(aset this "fileName" val))
(defn file-size
"Property.
Returns the size of a file in bytes.
`var size = instanceOfFile.fileSize;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/fileSize`"
[this]
(-> this (.fileSize)))
(defn set-file-size!
"Property.
Returns the size of a file in bytes.
`var size = instanceOfFile.fileSize;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/fileSize`"
[this val]
(aset this "fileSize" val))
(defn last-modified-date
"Property.
The File.lastModifiedDate read-only property returns the last
date of the file. Files without a known last modified date returns
current date .
`var time = instanceOfFile.lastModifiedDate`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/lastModifiedDate`"
[this]
(-> this (.lastModifiedDate)))
(defn moz-full-path
"Property.
A privileged exension to the `web.files.File` interface, the
property contains the full pathname of the represented file.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/mozFullPath`"
[this]
(-> this (.mozFullPath)))
(defn set-moz-full-path!
"Property.
A privileged exension to the `web.files.File` interface, the
property contains the full pathname of the represented file.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/mozFullPath`"
[this val]
(aset this "mozFullPath" val))
(defn name
"Property.
Returns the name of the file represented by a `web.files.File`
For security reasons, the path is excluded from this property.
`var name = file.name;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/name`"
[this]
(-> this (.name)))
(defn set-name!
"Property.
Returns the name of the file represented by a `web.files.File`
For security reasons, the path is excluded from this property.
`var name = file.name;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/name`"
[this val]
(aset this "name" val))
(defn type
"Property.
Returns the media type (MIME) of the file represented by a `web.files.File`
`var name = file.type;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/type`"
[this]
(-> this (.type)))
(defn set-type!
"Property.
Returns the media type (MIME) of the file represented by a `web.files.File`
`var name = file.type;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/type`"
[this val]
(aset this "type" val))
(defn webkit-relative-path
"Property.
The File.webkitRelativePath is a read-only property that contains
`web.USVString` which specifies the file's path relative to the
selected by the user in an `<input>` element with its webkitdirectory
set.
`relativePath = File.webkitRelativePath`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath`"
[this]
(-> this (.webkitRelativePath)))