blob: 408fe28a2f0c8633413b3bd15896b1dd3d0e4d0f (
plain)
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
|
---
title: Blob.size
slug: Web/API/Blob/size
tags:
- API
- Blob
- Bytes
- File API
- Files
- Property
- Reference
- length
- size
translation_of: Web/API/Blob/size
---
<div class="boxed translate-rendered text-content">
<div>{{APIRef("File API")}}</div>
<p>{{domxref("Blob")}} インターフェイスの <strong><code>size</code></strong> プロパティは、{{domxref("Blob")}} または {{domxref("File")}} のサイズをバイト単位で返します。</p>
<h2 id="シンタックス">シンタックス</h2>
<pre class="syntaxbox notranslate">var <em>sizeInBytes</em> = <em>blob</em>.size
</pre>
<h3 id="値">値</h3>
<p><code>Blob</code> (または <code>Blob</code> ベースのオブジェクト、例えば{{domxref("File")}}) 内に含まれるデータのバイト数。</p>
<h2 id="例">例</h2>
<p>この例では、<code>file</code> 型の {{HTMLElement("input")}} 要素を使用して、ユーザーにファイルのグループを尋ね、それらのファイルを繰り返し処理して、その名前と長さをバイト単位で出力しています。</p>
<pre class="brush:js notranslate">// fileInputは HTMLInputElement <input type="file" multiple id="myfileinput"> です。
var fileInput = document.getElementById("myfileinput");
// files は FileList オブジェクトです (NodeList に似ています)。
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
console.log(files[i].name + " has a size of " + files[i].size + " Bytes");
}</pre>
<h2 id="仕様">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様書</th>
<th scope="col">ステータス</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('File API', '#dfn-size', 'Blob.size')}}</td>
<td>{{Spec2('File API')}}</td>
<td>初期定義</td>
</tr>
</tbody>
</table>
<h2 id="ブラウザの互換性">ブラウザの互換性</h2>
<div>
<p>{{Compat("api.Blob.size")}}</p>
</div>
<h2 id="あわせて参照">あわせて参照</h2>
<ul>
<li>{{domxref("Blob")}}</li>
<li>
<p><a href="/ja/docs/Web/API/File/Using_files_from_web_applications">Web アプリケーションからのファイルの使用</a></p>
</li>
</ul>
</div>
|