Background Sync を使った障害に強いファイルアップロード
送信を試みる前にファイルを保存します。このチュートリアルでは、小さなファイルを IndexedDB のキューに保存し、オフラインでページを再読み込みしても保持したまま、認証付きのローカル受信サーバーへ配信します。サーバーがアップロードを保存したのに応答が届かなかった場合も、固定キーとファイルのバイト列に紐づく受領証により、安全に再試行できます。
Background Sync は、サービスワーカーに再試行の機会を与えます。セキュアコンテキストが必要で、対応ブラウザーは限られています。ブラウザーを閉じた後の配信を保証するものではありません。フォアグラウンドでの再試行ボタンを残し、ブラウザーのストレージは削除される場合があることにも注意してください。
チャンク分割アップロードの仕組み
この例では、ファイル全体を再試行します。対象は一バイトから 10 MiB までで、キューには全アカウント合計で最大 10 ファイルを保存でき、再試行期間は 24 時間です。チャンク分割は中断後の再送信量を減らしますが、ページのメモリーにしかないファイルは保持しません。大きなファイルでは tus がオフセットを調整しますが、元のバイト列の保持とサーバーの認証は引き続き必要です。
この別の課題については、再開可能なクライアントのチュートリアルで説明しています。そこで使うサーバーの契約は、以下の生のバイト列を受け取るサーバーとは異なります。
Fetch はすでにネットワーク I/O を非同期で実行します。ここでは Web Lock を使い、同じオリジン内のページとサービスワーカーによる再試行を直列化します。専用の Web Workers を追加しても、永続化やサーバーでのアトミックな公開は実現しません。
ローカルプロジェクトのセットアップ
Corepack が利用できる Node.js 24.15.0、Yarn 4.12.0 と、IndexedDB、Web Locks、サービスワーカーに対応したブラウザーを使用してください。ブラウザー側の動作は Chromium 145 でテストしています。サーバーが出力するループバックオリジンをそのまま使用してください。ループバック上の HTTP はセキュアコンテキストです。デプロイ時には HTTPS とアプリケーションの認証が必要です。
デモを作成する親ディレクトリで、以下を Bash に貼り付けてください。既存のプロジェクトディレクトリがある場合は処理を拒否し、成功時も失敗時もシェルの元のディレクトリを維持します。ローカルのロックファイルと明示的なバンドラー設定により、上位のプロジェクトから分離します。
(
mkdir background-upload-demo &&
cd background-upload-demo &&
printf '%s\n' '{"name":"background-upload-demo","private":true,"type":"module","packageManager":"yarn@4.12.0"}' > package.json &&
printf '%s\n' 'nodeLinker: node-modules' > .yarnrc.yml &&
touch yarn.lock &&
corepack yarn add --exact idb@8.0.3 esbuild@0.27.3
)
以下のファイルを background-upload-demo 内に保存してください。public/index.html を保存する際に、その public ディレクトリを作成してください。既存のアプリケーション、クラウドアカウント、アップロードエンドポイントは不要です。
バイト列と受領証を同時にコミットする受信サーバーの実行
server.mts を保存してください。ループバックでのみ待ち受け、起動時にデモ用の二つのアカウントの新しいパスワードを出力します。ログインすると HttpOnly Cookie のセッションが作成されます。変更リクエストでは、オリジン、セッション所有者、CSRF トークンも一致する必要があります。ブラウザーはキューとともにアカウント ID だけを保存し、再試行のたびに現在のセッションのトークンを取得します。
受信サーバーは BLOB、サイズ、SHA-256 ダイジェスト、キー、所有者を SQLite の一つの行に保存します。トランザクションで容量制限の確認と挿入を直列化します。コミット後は 201 を返し、同一の再送には同じ受領証とともに 200 を返します。バイト列やタイムスタンプが変わると 409、期限切れのキーには 410 を返します。再送時に新しいタイムスタンプを指定しても同様です。このデモは行を永続的に保持するため、受領証の削除によって、以前受け付けたキーを誤って新規のキーとして扱うことはありません。
SQLite のアトミックコミットのドキュメントでは、ストレージの境界について説明しています。ここでは Node 組み込みの SQLite APIを使用します。テストした Node バージョンではリリース候補です。永続化は正常に動作するローカルディスクを前提としており、複製型ストレージサービスではありません。
import { createHash, randomUUID } from 'node:crypto'
import { readFile } from 'node:fs/promises'
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'
import { DatabaseSync } from 'node:sqlite'
import { parseArgs } from 'node:util'
const { values } = parseArgs({ options: { port: { type: 'string', default: '8090' } } })
const port = Number(values.port)
if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error('Invalid port')
const maxSize = 10 * 1024 * 1024
const lifetime = 24 * 60 * 60 * 1000
const passwords = { alice: randomUUID(), bob: randomUUID() }
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
let origin = ''
class HttpError extends Error {
status: number
constructor(status: number, message: string) { super(message); this.status = status }
}
async function body(request: IncomingMessage, limit: number): Promise<Buffer> {
const chunks: Buffer[] = []
let size = 0
for await (const chunk of request) {
if (!Buffer.isBuffer(chunk)) throw new HttpError(400, 'Invalid body')
size += chunk.length
if (size > limit) throw new HttpError(413, 'File too large')
chunks.push(chunk)
}
return Buffer.concat(chunks)
}
async function main(): Promise<void> {
const db = new DatabaseSync('uploads.sqlite')
db.exec(`
PRAGMA journal_mode = WAL;
PRAGMA synchronous = FULL;
PRAGMA busy_timeout = 5000;
CREATE TABLE IF NOT EXISTS sessions (
id TEXT PRIMARY KEY, owner TEXT NOT NULL, csrf TEXT NOT NULL, expires INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS uploads (
owner TEXT NOT NULL, id TEXT NOT NULL, created INTEGER NOT NULL,
sha256 TEXT NOT NULL, size INTEGER NOT NULL, bytes BLOB NOT NULL,
PRIMARY KEY (owner, id)
);
`)
const reply = (response: ServerResponse, status: number, value: unknown) => {
response.writeHead(status, { 'Content-Type': 'application/json' })
response.end(JSON.stringify(value))
}
async function handle(request: IncomingMessage, response: ServerResponse): Promise<void> {
response.setHeader('Cache-Control', 'no-store')
response.setHeader('X-Content-Type-Options', 'nosniff')
if (request.headers.host !== new URL(origin).host) throw new HttpError(403, 'Wrong host')
const path = new URL(request.url ?? '/', origin).pathname
if (request.method === 'POST' && request.headers.origin !== origin) {
throw new HttpError(403, 'Wrong origin')
}
if (path === '/login' && request.method === 'GET') {
response.writeHead(200, { 'Content-Type': 'text/html' })
response.end(`<!doctype html><html lang="en"><meta name="viewport" content="width=device-width">
<meta name="color-scheme" content="light dark"><title>Local upload login</title><form method="post" action="/login">
<label>Account <select name="owner"><option>alice</option><option>bob</option></select></label>
<label>Password <input name="password" type="password" autocomplete="current-password" required></label>
<button>Sign in</button></form></html>`)
return
}
if (path === '/login' && request.method === 'POST') {
const form = new URLSearchParams((await body(request, 2048)).toString('utf8'))
const owner = form.get('owner')
if ((owner !== 'alice' && owner !== 'bob') || form.get('password') !== passwords[owner]) {
throw new HttpError(401, 'Invalid local login')
}
const id = randomUUID()
db.prepare('INSERT INTO sessions VALUES (?, ?, ?, ?)').run(id, owner, randomUUID(), Date.now() + lifetime)
response.setHeader('Set-Cookie', `session=${id}; HttpOnly; SameSite=Strict; Path=/; Max-Age=86400`)
response.writeHead(303, { Location: '/' }).end()
return
}
const cookie = request.headers.cookie?.split(';').map(part => part.trim()).find(part => part.startsWith('session='))
const session = db.prepare('SELECT * FROM sessions WHERE id = ? AND expires > ?').get(cookie?.slice(8) ?? '', Date.now())
if (path.startsWith('/api/') || path === '/received') {
if (!session) throw new HttpError(401, 'Sign in again')
}
if (path === '/api/upload-session' && request.method === 'GET') {
reply(response, 200, { owner: session?.owner, csrf: session?.csrf })
return
}
if (path === '/api/queued-uploads' && request.method === 'POST') {
if (!session || request.headers['x-upload-owner'] !== session.owner || request.headers['x-csrf-token'] !== session.csrf) {
throw new HttpError(403, 'Owner or CSRF mismatch')
}
const id = request.headers['idempotency-key']
const created = Number(request.headers['x-upload-created'])
if (typeof id !== 'string' || !uuid.test(id) || !Number.isSafeInteger(created)) {
throw new HttpError(400, 'Invalid upload identity')
}
if (request.headers['content-type'] !== 'application/octet-stream') throw new HttpError(415, 'Send raw bytes')
const bytes = await body(request, maxSize)
if (bytes.length === 0) throw new HttpError(400, 'Choose a nonempty file')
const sha256 = createHash('sha256').update(bytes).digest('hex')
let status = 200
db.exec('BEGIN IMMEDIATE')
try {
const previous = db.prepare('SELECT * FROM uploads WHERE owner = ? AND id = ?').get(session.owner, id)
const originalCreated = previous?.created ?? created
if (typeof originalCreated !== 'number' || Date.now() - originalCreated >= lifetime) {
throw new HttpError(410, 'Upload expired')
}
if (created > Date.now() + 60_000) throw new HttpError(400, 'Clock is ahead')
if (previous) {
if (previous.sha256 !== sha256 || previous.size !== bytes.length || previous.created !== created) {
throw new HttpError(409, 'Key already belongs to different content')
}
} else {
const usage = db.prepare('SELECT COALESCE(SUM(size), 0) AS total FROM uploads WHERE owner = ?').get(session.owner)
if (typeof usage?.total !== 'number' || usage.total + bytes.length > 100 * 1024 * 1024) {
throw new HttpError(429, 'Local account quota reached')
}
db.prepare('INSERT INTO uploads VALUES (?, ?, ?, ?, ?, ?)').run(session.owner, id, created, sha256, bytes.length, bytes)
status = 201
}
db.exec('COMMIT')
} catch (error) {
db.exec('ROLLBACK')
throw error
}
reply(response, status, { id, owner: session.owner, size: bytes.length, sha256 })
return
}
if (path === '/received' && request.method === 'GET') {
const rows = db.prepare('SELECT id, size, sha256 FROM uploads WHERE owner = ? ORDER BY id').all(session?.owner ?? '')
response.writeHead(200, { 'Content-Type': 'text/html' })
response.end(`<!doctype html><html lang="en"><meta name="color-scheme" content="light dark"><title>Received uploads</title>
<h1>Received uploads</h1><p>${rows.length} stored file(s)</p><ul>${rows.map(row =>
`<li><a href="/api/files/${row.id}">${row.id}</a>: ${row.size} bytes, SHA-256 ${row.sha256}</li>`
).join('')}</ul><a href="/">Queue</a></html>`)
return
}
if (path.startsWith('/api/files/') && request.method === 'GET') {
const row = db.prepare('SELECT bytes FROM uploads WHERE owner = ? AND id = ?').get(session?.owner ?? '', path.slice(11))
if (!row || !(row.bytes instanceof Uint8Array)) throw new HttpError(404, 'File not found')
response.writeHead(200, { 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="upload.bin"' })
response.end(row.bytes)
return
}
const files: Record<string, [string, string]> = {
'/': ['index.html', 'text/html'],
'/upload-page.js': ['upload-page.js', 'text/javascript'],
'/upload-sw.js': ['upload-sw.js', 'text/javascript'],
}
const file = files[path]
if (request.method !== 'GET' || !file) throw new HttpError(404, 'Not found')
const content = await readFile(new URL(`./public/${file[0]}`, import.meta.url))
response.writeHead(200, { 'Content-Type': file[1] })
response.end(content)
}
const server = createServer((request, response) => {
void handle(request, response).catch(error => {
if (!(error instanceof HttpError)) console.error('Receiver request failed')
response.setHeader('Connection', 'close')
reply(response, error instanceof HttpError ? error.status : 500, {
error: error instanceof HttpError ? error.message : 'Upload not confirmed',
})
})
})
server.requestTimeout = 30_000
await new Promise<void>((resolve, reject) => {
server.once('error', reject)
server.listen(port, '127.0.0.1', resolve)
})
const address = server.address()
if (!address || typeof address === 'string') throw new Error('No listening address')
origin = `http://127.0.0.1:${address.port}`
console.log(JSON.stringify({ ready: origin, passwords }))
const stop = () => {
server.close(() => db.close())
server.closeAllConnections()
}
process.once('SIGINT', stop)
process.once('SIGTERM', stop)
}
main().catch(error => { console.error('Receiver startup failed:', error.message); process.exitCode = 1 })
Background Sync の組み込み
queue.ts を保存してください。ハッシュ計算は挿入トランザクションの前に行い、フェッチの完了後に新しい削除トランザクションを開始します。IndexedDB のトランザクションは、無関係な非同期処理の待機中に閉じる場合があります。idb のトランザクションの有効期間に関するドキュメントを参照してください。tx.done を待機することで、ローカルへの書き込みのコミットを確認します。削除には、単なる HTTP 応答の成功ではなく、キー、所有者、サイズ、ダイジェストが一致する
200/201 の受領証が必要です。
import { openDB } from 'idb'
const maxSize = 10 * 1024 * 1024
const lifetime = 24 * 60 * 60 * 1000
const lockName = 'durable-file-uploads'
async function digest(file) {
const bytes = await crypto.subtle.digest('SHA-256', await file.arrayBuffer())
return Array.from(new Uint8Array(bytes), byte => byte.toString(16).padStart(2, '0')).join('')
}
async function database() {
return openDB('durable-file-uploads', 1, {
upgrade(db) {
db.createObjectStore('uploads', { keyPath: 'id' })
},
})
}
export async function enqueue(file, owner) {
if (!owner || !(file instanceof File) || file.size === 0 || file.size > maxSize) {
throw new Error('Choose a file between 1 byte and 10 MiB while signed in.')
}
const sha256 = await digest(file)
const db = await database()
try {
const tx = db.transaction('uploads', 'readwrite')
const id = crypto.randomUUID()
// Observe request and transaction failures together, including quota-induced aborts.
await Promise.all([
(async () => {
// Counting and inserting in one transaction also bounds concurrent tabs.
if ((await tx.store.count()) >= 10) {
throw new Error('The queue is full. Retry or discard queued files first.')
}
await tx.store.add({ id, owner, file, name: file.name, sha256, created: Date.now() })
})(),
tx.done,
])
return id
} finally {
db.close()
}
}
export async function drain(signal = new AbortController().signal) {
return navigator.locks.request(lockName, { signal }, async () => {
const db = await database()
try {
// The count is bounded at ten. No readwrite transaction spans a fetch.
const entries = await db.getAll('uploads')
if (entries.length === 0) return { sent: 0, remaining: 0 }
let sent = 0
const sessionResponse = await fetch('/api/upload-session', {
credentials: 'same-origin',
cache: 'no-store',
redirect: 'error',
signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]),
})
if (!sessionResponse.ok) throw new Error('Sign in again before retrying.')
const session = await sessionResponse.json()
if (
typeof session.owner !== 'string' ||
!session.owner ||
typeof session.csrf !== 'string' ||
!session.csrf
) {
throw new Error('Invalid upload session.')
}
for (const entry of entries) {
signal.throwIfAborted()
if (entry.owner !== session.owner) continue
if (Date.now() - entry.created >= lifetime) {
throw new Error('A queued file expired. Discard it before retrying.')
}
const response = await fetch('/api/queued-uploads', {
method: 'POST',
credentials: 'same-origin',
redirect: 'error',
body: entry.file,
headers: {
'Content-Type': 'application/octet-stream',
'X-Upload-Created': String(entry.created),
'X-CSRF-TOKEN': session.csrf,
'X-Upload-Owner': entry.owner,
'Idempotency-Key': entry.id,
},
signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]),
})
if (!response.ok || ![200, 201].includes(response.status)) {
throw new Error(`Upload not confirmed (HTTP ${response.status}).`)
}
const receipt = await response.json()
if (receipt.id !== entry.id || receipt.owner !== entry.owner ||
receipt.size !== entry.file.size || receipt.sha256 !== entry.sha256) {
throw new Error('Invalid upload receipt.')
}
const tx = db.transaction('uploads', 'readwrite')
await Promise.all([tx.store.delete(entry.id), tx.done])
sent++
}
return { sent, remaining: entries.length - sent }
} finally {
db.close()
}
})
}
export async function discard(owner) {
// Serialize with uploads so a deletion cannot race a foreground or background replay.
await navigator.locks.request(lockName, async () => {
const db = await database()
try {
const tx = db.transaction('uploads', 'readwrite')
await Promise.all([
(async () => {
for (const entry of await tx.store.getAll()) {
if (entry.owner === owner) await tx.store.delete(entry.id)
}
})(),
tx.done,
])
} finally {
db.close()
}
})
}
upload-sw.ts を保存してください。ワーカーは静的ページとそのバンドルだけをキャッシュするため、オンラインでの初回アクセスが成功すれば、オフラインでも再度開けます。ログイン、セッション、受領証、ファイルの応答は一切キャッシュしません。同期に失敗すると waitUntil が拒否され、確認応答のないエントリーは再試行できる状態で残ります。
import { drain } from './queue.ts'
const cacheName = 'upload-shell-v1'
const shell = ['/', '/upload-page.js']
self.addEventListener('install', event => {
event.waitUntil((async () => {
const cache = await caches.open(cacheName)
await cache.addAll(shell)
await self.skipWaiting()
})())
})
self.addEventListener('activate', event => event.waitUntil(self.clients.claim()))
self.addEventListener('fetch', event => {
const url = new URL(event.request.url)
if (event.request.method === 'GET' && url.origin === self.location.origin && shell.includes(url.pathname)) {
event.respondWith(fetch(event.request).catch(async () => {
const response = await caches.match(url.pathname)
return response ?? Response.error()
}))
}
})
self.addEventListener('sync', event => {
if (event.tag === 'file-upload-sync') event.waitUntil(drain())
})
public/index.html を保存してください。
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<title>Offline file queue</title>
</head>
<body>
<h1>Offline file queue</h1>
<p><a href="/login">Sign in or switch account</a> · <a href="/received">Received uploads</a></p>
<p id="account"></p>
<label>File <input id="file" type="file"></label>
<button id="queue" type="button">Queue file</button>
<button id="retry" type="button">Retry queued files</button>
<button id="stop" type="button">Stop foreground retry</button>
<button id="discard" type="button">Discard my queued files</button>
<p id="status" role="status"></p>
<script type="module" src="/upload-page.js"></script>
</body>
</html>
upload-page.ts を保存してください。フォアグラウンドの操作中はコントロールを無効にし、連続クリックで同じ選択内容が二重にキューへ追加されるのを防ぎます。Background Sync が利用できなくてもローカル保存は成功します。オフラインで開き直した場合、最後に確認したアカウント ID がキューのラベルになりますが、サーバーはバイト列を受け付ける前に、現在の Cookie セッションを引き続き検証します。
import { discard, drain, enqueue } from './queue.ts'
const input = document.getElementById('file')
const status = document.getElementById('status')
const account = document.getElementById('account')
const controls = ['queue', 'retry', 'discard'].map(id => document.getElementById(id))
let owner = localStorage.getItem('upload-owner')
let busy = false
let controller = null
let registration = null
function available() {
return owner && 'indexedDB' in globalThis && navigator.locks
}
function render() {
account.textContent = owner ? `Local queue owner: ${owner}` : 'Sign in online before queuing files.'
input.disabled = busy || !available()
for (const button of controls) button.disabled = busy || !available()
}
async function schedule() {
if (!registration?.sync) return false
await registration.sync.register('file-upload-sync')
return true
}
async function action(operation) {
if (busy) return
busy = true
render()
try { await operation() }
catch { status.textContent = 'Retry stopped or failed. Some files may already be received; others remain queued.' }
finally { busy = false; controller = null; render() }
}
document.getElementById('queue').onclick = () => action(async () => {
const file = input.files?.[0]
if (!file) return
try {
await enqueue(file, owner)
input.value = ''
status.textContent = 'Saved locally. Use Retry queued files to upload now.'
} catch {
status.textContent = 'Could not save. Check the 10 MiB file limit, ten-file queue limit, and available storage.'
return
}
try {
if (await schedule()) status.textContent = 'Saved locally. Background retry requested.'
} catch { status.textContent = 'Saved locally. Background retry unavailable; use Retry queued files.' }
})
document.getElementById('retry').onclick = () => action(async () => {
controller = new AbortController()
const result = await drain(controller.signal)
status.textContent = `Delivered ${result.sent} file(s). ${result.remaining} remain queued.`
})
document.getElementById('stop').onclick = () => controller?.abort()
document.getElementById('discard').onclick = () => action(async () => {
await discard(owner)
status.textContent = 'Local queue discarded. Already received uploads remain on the server.'
})
render()
try {
const response = await fetch('/api/upload-session', { cache: 'no-store', redirect: 'error' })
if (response.ok) {
const session = await response.json()
if (!['alice', 'bob'].includes(session.owner)) throw new Error('Invalid session')
owner = session.owner
localStorage.setItem('upload-owner', owner)
} else if (response.status === 401) {
owner = null
localStorage.removeItem('upload-owner')
}
} catch { /* Offline: retain only the previously observed account ID, never credentials. */ }
render()
if (!available()) status.textContent = 'Durable uploads require sign-in, IndexedDB, and Web Locks.'
try {
if ('serviceWorker' in navigator) {
registration = await navigator.serviceWorker.register('/upload-sw.js')
await navigator.serviceWorker.ready
status.textContent = 'Ready for offline use. Background Sync is optional.'
}
} catch { status.textContent = 'Offline page setup failed. Keep this page open to queue and retry.' }
元の親ディレクトリから両方のバンドルをビルドし、受信サーバーを起動してください。&& の連結により、どちらかのビルドが失敗すると、古いバンドルが残っていても起動前に停止します。Ctrl+C で受信サーバーを停止すると、同じシェルに戻ります。ポート 8090 が使用中なら、別のポートを選び、そのオリジンを使い続けてください。ブラウザーのストレージは、ポートを含むオリジン単位で管理されます。
(
cd background-upload-demo &&
corepack yarn esbuild upload-page.ts --bundle --format=esm --target=es2022 --tsconfig-raw='{}' --outfile=public/upload-page.js &&
corepack yarn esbuild upload-sw.ts --bundle --format=iife --target=es2022 --tsconfig-raw='{}' --outfile=public/upload-sw.js &&
node server.mts --port=8090
)
ターミナルに ready と一時的な passwords を含む
JSON オブジェクトが出力されます。http://127.0.0.1:8090/login を開き、alice を選択して、出力されたパスワードを入力し、Sign in を押してください。Ready for offline use. Background Sync is optional. が表示されてから接続を切ってください。再起動するとパスワードは変わりますが、有効期限内の既存セッションと受信済みアップロードは
background-upload-demo/uploads.sqlite に残ります。
- ブラウザーをオフラインにするか受信サーバーを停止し、空でない 10 MiB 以下のファイルを選択して、Queue file を押してください。Saved locally. で始まるメッセージは、配信ではなく IndexedDB へのコミットを確認するものです。
- オフラインのまま同じオリジンでページを再読み込みするか、閉じて開き直してください。キャッシュ済みのページが読み込まれ、ファイルを選び直す必要はありません。
- 再接続してください。対応ブラウザーでは、Background Sync によってキューが配信される場合があります。フォアグラウンドでの試行を要求するには、Retry queued files を押してください。
- Received uploads を開いてください。保存済みの各ファイルには、一つのキー、バイト数、SHA-256 ダイジェスト、ダウンロードリンクがあります。
upload.binをダウンロードし、元のファイルとバイト列を比較してください。同じキューエントリーを再試行しても、保存された行は一つのままで、受領証も同じである必要があります。
DevTools でページのリクエストだけを切断しても、ワーカーはオンラインのままの場合があります。手動でオフライン動作を確認するには、ページの準備後に受信サーバーを停止してから、キューへの追加と再読み込みを行ってください。再試行前に同じポートで再起動します。ブラウザーのスケジューリングはベストエフォートなので、バックグラウンド試行が実行されなくても、キューが失われた証拠ではありません。その場合はボタンを使ってください。
未確認のアップロードを成功扱いせずに復旧
401 は再ログインが必要なことを示します。別のアカウントが有効な場合、再試行では元の所有者のエントリーをスキップします。配信するにはその所有者として再ログインするか、Discard my queued files でローカルコピーを削除してください。破棄しても、サーバーが受信済みのファイルは削除されません。ユーザーの同意なしに、機密ファイルを共有端末に保持しないでください。
ファイルの期限切れ、HTTP エラー、受領証の不一致、リクエストの中断が起きても、キューには残ります。それ以前のエントリーの一部は、すでに届いている場合があります。破棄する前に受信済み一覧を確認してください。変更のないエントリーは、再試行期間内なら安全に再試行できます。サーバーのアカウントごとの 100 MiB の容量制限には、保持しているすべてのファイルが含まれます。容量がいっぱいになった場合は、クリックを繰り返すのではなく、意図的なデータ管理が必要です。ローカル書き込みに失敗した場合は、配信メッセージではなく、必ず保存失敗を表示する必要があります。
Stop foreground retry は、現在のページの試行だけを中止します。コミット済みのアップロードを取り消したり、別途スケジュールされたバックグラウンド試行をキャンセルしたりすることはできません。Web Lock はローカルでの破棄と配信も直列化するため、一方の処理中に他方がエントリーを削除することはありません。
デプロイ時は、デモ用のパスワードとセッションを既存のログインシステムに置き換え、オブジェクトを削除する際も受領証または永続的な期限切れ記録を保持し、公開前にメディアポリシーを適用してください。このループバックの例は、空でない任意のバイト列を非公開ダウンロードとして受け付けますが、ファイルのセキュリティスキャン、ログインのレート制限、ストレージの複製は行わず、ブラウザーによるストレージ削除後の復旧も保証しません。より大きなファイルでは、再開可能なプロトコルでも同じ所有権と受領確認の検証を維持してください。
