Web ブラウザー経由で SFTP サーバーにファイルをエクスポート
ブラウザーから HTTP ゲートウェイにファイルを送信し、ゲートウェイから SSH 経由で SFTP サーバーに書き込めます。使い捨ての OpenSSH サーバー、固定したホスト鍵、有効期間の短いアクセストークンを使い、この経路をローカルで構築します。ブラウザーでファイルを選び、非公開の受信ディレクトリで同じバイト列を検証します。
はじめに
この例では、空のファイルから 5 MiB までを受け付け、それぞれにランダムな受領 ID を割り当てます。ブラウザーは送信するバイト列を選び、ゲートウェイはサーバー、アカウント、ディレクトリ、ファイル名を選びます。データの内容は解釈せずにエクスポートし、マルウェアのスキャンや、ドキュメントを安全に実行できるようにする処理は行いません。
課題の理解
通常の Web ページからは SSH 接続を開けないため、ブラウザーから SFTP にアップロードするにはゲートウェイが必要です。ブラウザーは Bearer トークンでゲートウェイに認証します。それとは別に、ゲートウェイは SSH サーバーの識別情報を検証し、自身の秘密鍵で認証します。この鍵はサーバー側に保持してください。ブラウザーを使わないプログラムからの転送については、Node.js SFTP ガイドを参照してください。
分離したローカルプロジェクトの作成
Bash、Docker Engine、OpenSSH の ssh-keygen、Node.js 24.15.0 以降の Node.js 24
リリース、および Yarn 4.12.0 を提供する Corepack を備えた Linux を使用してください。Node.js 24 は保守対象の LTS 系列です。この例は
Node.js 26.8.1 でも動作します。.mts ファイルは
Node のネイティブ TypeScript 実行機能を使用するため、親プロジェクトのモジュールタイプを継承しません。
プロジェクトを作成するディレクトリで、次の内容を Bash に貼り付けてください。サブシェルを使うため、成功しても失敗しても現在のディレクトリとシェルオプションは変わりません。ローカルのロックファイルと明示的なリンカー設定により、インストールを親の Yarn ワークスペースから分離します。既存の sftp-upload ディレクトリがある場合は処理を拒否します。インストールが中断すると、新しく作成された不完全なディレクトリが残る場合があるため、内容を確認してください。
(
set -eu
mkdir sftp-upload
cd sftp-upload
printf '%s\n' '{"private":true,"type":"module","packageManager":"yarn@4.12.0"}' > package.json
touch yarn.lock
printf 'nodeLinker: node-modules\nenableGlobalCache: false\n' > .yarnrc.yml
mkdir .corepack
printf '%s\n' '{"type":"commonjs"}' > .corepack/package.json
COREPACK_HOME="$PWD/.corepack" YARN_IGNORE_PATH=1 corepack yarn add --exact express@5.2.1 helmet@8.3.0 jose@6.2.12 ssh2-sftp-client@12.1.1 execa@9.6.1
mkdir public
)
インストールが成功してから、プロジェクトに移動してください。
cd sftp-upload
受信ディレクトリと開発用トークン発行機能の準備
次の内容を demo.mts として保存してください。OpenSSH を含む Ubuntu 24.04 イメージをビルドし、SFTP 専用アカウントを作成して、ランダムに割り当てたループバックポートで SSH を公開します。chroot は root が所有し、アカウントが書き込めるのはモード 700 の /incoming だけです。OpenSSH では chroot ディレクトリを root が所有する必要があります。
すべての認証情報は、このデモ用に非公開の .demo ディレクトリ内に生成します。既存のアカウント、SSH 鍵、known-hosts ファイルは変更しません。固定するホスト鍵の値は、未検証の SSH 接続ではなく、自分で管理するローカルの
Docker デーモン経由で読み取った公開鍵から導出します。ローカルの RSA 鍵で jose の SignJWT を使用し、有効期間が五分の RS256 トークンを発行します。この開発用発行機能にはログイン機能もユーザーディレクトリもありません。決してデプロイしたり、署名鍵を共有したりしないでください。
import { createHash, generateKeyPairSync, randomUUID } from 'node:crypto'
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { execa } from 'execa'
import { importPKCS8, SignJWT } from 'jose'
import SftpClient from 'ssh2-sftp-client'
const directory = join(import.meta.dirname, '.demo')
const statePath = join(directory, 'state.json')
const docker = (args, options = {}) => execa('docker', args, { timeout: 180_000, ...options })
async function setup() {
const prefix = process.env.SFTP_DEMO_PREFIX ?? 'sftp-demo'
if (!/^[a-z0-9-]{1,40}$/.test(prefix)) throw new Error('Invalid demo prefix')
const name = prefix + '-' + randomUUID()
await mkdir(directory, { mode: 0o700 }) // Refuse to replace an existing demo.
let ready = false
try {
await mkdir(join(directory, 'staging'), { mode: 0o700 })
await execa('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', join(directory, 'client')])
const pair = generateKeyPairSync('rsa', { modulusLength: 2048 })
await writeFile(join(directory, 'jwt-private.pem'), pair.privateKey.export({ type: 'pkcs8', format: 'pem' }), { mode: 0o600 })
await writeFile(join(directory, 'jwt-public.pem'), pair.publicKey.export({ type: 'spki', format: 'pem' }), { mode: 0o600 })
const [keyType, keyBytes] = (await readFile(join(directory, 'client.pub'), 'utf8')).split(' ')
const config = `Port 22
HostKey /etc/ssh/ssh_host_ed25519_key
AuthorizedKeysFile /etc/ssh/demo_authorized_keys
PasswordAuthentication no
KbdInteractiveAuthentication no
UsePAM no
PermitRootLogin no
AllowUsers uploader
Subsystem sftp internal-sftp
Match User uploader
ChrootDirectory /srv/sftp
ForceCommand internal-sftp -u 077
DisableForwarding yes
PermitTTY no`
await docker(['build', '--tag', name, '-'], { input: `FROM ubuntu:24.04
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && rm -rf /var/lib/apt/lists/* /etc/ssh/ssh_host_*
RUN useradd --no-create-home --home-dir /incoming --shell /usr/sbin/nologin uploader && passwd -d uploader && mkdir -p /run/sshd /srv/sftp/incoming && chown uploader:uploader /srv/sftp/incoming && chmod 700 /srv/sftp/incoming && chmod 755 /srv/sftp
RUN printf '%s\\n' '${keyType} ${keyBytes}' > /etc/ssh/demo_authorized_keys
RUN printf '%s\\n' '${config.replaceAll('\n', "' '")}' > /etc/ssh/sshd_config
CMD ["sh", "-c", "ssh-keygen -A && exec /usr/sbin/sshd -D -e"]
` })
await docker(['run', '--detach', '--rm', '--name', name, '--publish', '127.0.0.1::22', name])
let publicKey
for (let attempt = 0; attempt < 50; attempt++) {
const probe = await docker(['exec', name, 'cat', '/etc/ssh/ssh_host_ed25519_key.pub'], { reject: false })
if (probe.exitCode === 0) { publicKey = probe.stdout; break }
const running = await docker(['inspect', '--format', '{{.State.Running}}', name], { reject: false })
if (running.stdout !== 'true') throw new Error('Disposable SFTP server exited during startup')
await new Promise((resolve) => setTimeout(resolve, 100))
}
if (!publicKey) throw new Error('Disposable SFTP server did not become ready')
const mapping = await docker(['port', name, '22/tcp'])
const port = Number(mapping.stdout.split(':').at(-1))
const hostKey = createHash('sha256').update(Buffer.from(publicKey.split(' ')[1], 'base64')).digest('hex')
const sftp = new SftpClient()
try {
await sftp.connect({ host: '127.0.0.1', port, username: 'uploader', privateKey: await readFile(join(directory, 'client')), hostHash: 'sha256', hostVerifier: (hash) => hash === hostKey, readyTimeout: 10_000 })
if (await sftp.realPath('/incoming') !== '/incoming') throw new Error('Unexpected demo inbox')
} finally { await sftp.end() }
await writeFile(statePath, JSON.stringify({ name, port, hostKey }) + '\n', { mode: 0o600 })
ready = true
console.log('Local SFTP inbox ready. Next: node demo.mts token')
} finally {
if (!ready) {
await docker(['rm', '--force', name], { reject: false })
await docker(['image', 'rm', '--force', name], { reject: false })
await rm(directory, { recursive: true, force: true })
}
}
}
async function main() {
const [command, id, original] = process.argv.slice(2)
if (command === 'setup') return setup()
const state = JSON.parse(await readFile(statePath, 'utf8'))
if (command === 'stop') {
await docker(['rm', '--force', state.name])
await docker(['image', 'rm', '--force', state.name])
await rm(directory, { recursive: true })
console.log('Removed the disposable server, inbox, and demo credentials')
return
}
if (command === 'verify') {
if (!/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/.test(id ?? '') || !original) throw new Error('Usage: node demo.mts verify RECEIPT_ID ORIGINAL_FILE')
const path = '/srv/sftp/incoming/' + id + '.bin'
const remote = await docker(['exec', state.name, 'cat', path], { encoding: 'buffer', stripFinalNewline: false })
const expected = await readFile(original)
const mode = await docker(['exec', state.name, 'stat', '-c', '%a', path])
if (Buffer.compare(remote.stdout, expected) !== 0 || mode.stdout !== '600') throw new Error('Remote bytes or file permissions differ')
console.log('Verified ' + expected.length + ' bytes; mode 600')
return
}
if (command === 'token') {
const key = await importPKCS8(await readFile(join(directory, 'jwt-private.pem'), 'utf8'), 'RS256')
console.log(await new SignJWT({ scope: 'sftp:upload' }).setProtectedHeader({ alg: 'RS256' }).setIssuer('urn:local-sftp-demo').setAudience('sftp-gateway').setSubject('local-uploader').setIssuedAt().setExpirationTime('5m').sign(key))
return
}
if (command !== 'serve') throw new Error('Use setup, token, serve, verify, or stop')
const port = Number(process.env.PORT ?? 3000)
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('Invalid HTTP port')
Object.assign(process.env, {
PORT: String(port), APP_ORIGIN: 'http://127.0.0.1:' + port,
JWT_PUBLIC_KEY: await readFile(join(directory, 'jwt-public.pem'), 'utf8'),
JWT_ISSUER: 'urn:local-sftp-demo', JWT_AUDIENCE: 'sftp-gateway',
SFTP_HOST: '127.0.0.1', SFTP_PORT: String(state.port), SFTP_USERNAME: 'uploader',
SFTP_PRIVATE_KEY: await readFile(join(directory, 'client'), 'utf8'), SFTP_HOST_SHA256: state.hostKey,
TMPDIR: join(directory, 'staging'),
})
await import('./index.mts')
}
main().catch((error) => {
console.error(error instanceof Error ? error.message : 'Demo failed')
process.exitCode = 1
})
フロントエンドの設定
次の内容を public/index.html として保存してください。トークン欄は、このローカルデモで手動入力するためのものです。アプリケーションでは、ログインフローを通じて、認可された各ユーザーの有効期間の短いトークンを取得する必要があります。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SFTP file export</title>
</head>
<body>
<h1>Export a file</h1>
<form id="uploadForm">
<label>Your access token <input id="token" type="password" autocomplete="off" required /></label>
<label>File (up to 5 MiB) <input type="file" id="fileInput" required /></label>
<button type="submit">Export to SFTP</button>
</form>
<p id="status" role="status"></p>
<script src="/upload.js" defer></script>
</body>
</html>
次の内容を public/upload.js として保存してください。ブラウザーは、長さゼロのファイルも含めて File をリクエストボディとして送信し、その Content-Length を指定します。リクエストの処理中はコントロールを無効にし、重複送信を無視します。送信前に、入力欄からトークンを消去します。
const form = document.getElementById('uploadForm')
const token = document.getElementById('token')
const input = document.getElementById('fileInput')
const status = document.getElementById('status')
const button = form.querySelector('button')
form.addEventListener('submit', async (event) => {
event.preventDefault()
if (button.disabled) return
const file = input.files[0]
if (!file || file.size > 5 * 1024 * 1024) {
status.textContent = 'Choose a file of up to 5 MiB.'
return
}
button.disabled = true
input.disabled = true
token.disabled = true
status.textContent = 'Exporting…'
const accessToken = token.value
token.value = ''
try {
const response = await fetch('/upload', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + accessToken,
'Content-Type': 'application/octet-stream',
},
body: file,
signal: AbortSignal.timeout(35_000),
})
if (!response.ok) throw new Error('Export rejected')
const result = await response.json()
status.textContent = 'File exported. Receipt: ' + result.id
} catch {
status.textContent = 'Export could not be confirmed. Check your inbox before retrying.'
} finally {
button.disabled = false
input.disabled = false
token.disabled = false
}
})
Node.js によるバックエンド API の構築
次の内容を index.mts として保存してください。ssh2-sftp-client API は SFTP ストリームと名前変更操作を提供します。ssh2 の接続オプションで hostHash と
hostVerifier を定義します。固定値は生のホスト鍵の SHA-256 ダイジェストを表す
64 文字の 16 進数であり、OpenSSH の SHA256:base64 表示文字列ではありません。
ゲートウェイはボディを読み取る前に、トークンの署名、発行者、対象者、発行からの経過時間、アップロードスコープを検証します。サイズ制限内のボディ全体をローカルに一時保存し、非公開の .part ファイルに書き込みます。その後、.bin に名前を変更してから HTTP 201 と { id } を返します。利用側は .part ファイルを無視する必要があります。
import { randomUUID } from 'node:crypto'
import { createReadStream, createWriteStream } from 'node:fs'
import { mkdtemp, rm } from 'node:fs/promises'
import { createConnection } from 'node:net'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Transform } from 'node:stream'
import { pipeline } from 'node:stream/promises'
import { fileURLToPath } from 'node:url'
import express from 'express'
import helmet from 'helmet'
import { importSPKI, jwtVerify } from 'jose'
import SftpClient from 'ssh2-sftp-client'
const {
APP_ORIGIN, JWT_PUBLIC_KEY, JWT_ISSUER, JWT_AUDIENCE,
SFTP_HOST, SFTP_USERNAME, SFTP_PRIVATE_KEY, SFTP_HOST_SHA256,
} = process.env
if (!APP_ORIGIN || !JWT_PUBLIC_KEY || !JWT_ISSUER || !JWT_AUDIENCE ||
!SFTP_HOST || !SFTP_USERNAME || !SFTP_PRIVATE_KEY ||
!/^[a-f0-9]{64}$/.test(SFTP_HOST_SHA256 ?? '')) {
throw new Error('Gateway configuration is incomplete')
}
const sshPort = Number(process.env.SFTP_PORT ?? 22)
if (!Number.isInteger(sshPort) || sshPort < 1 || sshPort > 65535) {
throw new Error('Invalid SFTP port')
}
const key = await importSPKI(JWT_PUBLIC_KEY, 'RS256')
const webOrigin = new URL(APP_ORIGIN)
const localHttp = webOrigin.protocol === 'http:' &&
['localhost', '127.0.0.1', '[::1]'].includes(webOrigin.hostname)
if (webOrigin.origin !== APP_ORIGIN || (!localHttp && webOrigin.protocol !== 'https:')) {
throw new Error('Use an HTTPS origin or loopback HTTP for local development')
}
const remoteRoot = '/incoming'
const maxBytes = 5 * 1024 * 1024
let active = 0
export const app = express()
app.disable('x-powered-by')
app.use(helmet({
contentSecurityPolicy: {
// The local demo uses HTTP, so its assets must not be upgraded to HTTPS.
directives: { 'upgrade-insecure-requests': localHttp ? null : [] },
},
strictTransportSecurity: localHttp ? false : undefined,
}))
app.use((_req, res, next) => {
res.locals.requestId = randomUUID()
res.set('X-Request-ID', res.locals.requestId)
res.set('Cache-Control', 'no-store')
next()
})
app.post('/upload', async (req, res) => {
const fail = (status, error) => {
if (!res.destroyed && !res.headersSent) {
res.status(status).json({ error, requestId: res.locals.requestId })
}
}
if (req.get('origin') !== APP_ORIGIN || req.originalUrl !== '/upload') {
return fail(403, 'Request not allowed')
}
let claims
try {
const match = /^Bearer ([A-Za-z0-9_.-]+)$/.exec(req.get('authorization') ?? '')
if (!match) return fail(401, 'Authentication required')
const verified = await jwtVerify(match[1], key, {
algorithms: ['RS256'], issuer: JWT_ISSUER, audience: JWT_AUDIENCE,
requiredClaims: ['sub', 'exp', 'iat'], maxTokenAge: '15m',
})
claims = verified.payload
} catch {
return fail(401, 'Invalid access token')
}
if (typeof claims.scope !== 'string' || !claims.scope.split(' ').includes('sftp:upload')) {
return fail(403, 'Permission denied')
}
const length = req.get('content-length') ?? ''
if (!/^(0|[1-9][0-9]*)$/.test(length)) return fail(411, 'Content length required')
const expected = Number(length)
if (!Number.isSafeInteger(expected) || expected > maxBytes) return fail(413, 'File too large')
if (req.get('content-type') !== 'application/octet-stream') {
return fail(415, 'Send an octet-stream file')
}
if (active >= 2) return fail(503, 'Gateway busy')
active += 1
const id = randomUUID()
const remotePart = remoteRoot + '/' + id + '.part'
const remoteFinal = remoteRoot + '/' + id + '.bin'
const abort = new AbortController()
const timer = setTimeout(() => abort.abort(), 30_000)
const disconnect = () => { if (!res.writableFinished) abort.abort() }
req.once('aborted', disconnect)
res.once('close', disconnect)
let directory
let socket
let connected = false
let pending = false
const sftp = new SftpClient('gateway', {
error: () => abort.abort(),
end: () => abort.abort(),
close: () => abort.abort(),
})
const cancelSocket = () => socket?.destroy()
abort.signal.addEventListener('abort', cancelSocket)
try {
directory = await mkdtemp(join(tmpdir(), 'sftp-upload-'))
const localPath = join(directory, 'payload')
let received = 0
const limit = new Transform({
transform(chunk, _encoding, callback) {
received += chunk.length
callback(received > expected ? new Error('Byte limit exceeded') : null, chunk)
},
flush(callback) {
callback(received !== expected ? new Error('Incomplete upload') : null)
},
})
await pipeline(req, limit, createWriteStream(localPath, { flags: 'wx', mode: 0o600 }), {
signal: abort.signal,
})
abort.signal.throwIfAborted()
socket = createConnection({ host: SFTP_HOST, port: sshPort })
// ssh2 observes socket failures; this also covers the handoff before its listeners attach.
socket.on('error', () => {})
await sftp.connect({
sock: socket,
username: SFTP_USERNAME,
privateKey: SFTP_PRIVATE_KEY,
hostHash: 'sha256',
hostVerifier: (hash) => hash === SFTP_HOST_SHA256,
readyTimeout: 10_000,
})
connected = true
abort.signal.throwIfAborted()
if (await sftp.realPath(remoteRoot) !== remoteRoot) throw new Error('Unexpected inbox')
pending = true
// The private inbox has no other writers; exclusive creation refuses an existing .part file.
await pipeline(
createReadStream(localPath),
sftp.createWriteStream(remotePart, { flags: 'wx', mode: 0o600 }),
{ signal: abort.signal },
)
abort.signal.throwIfAborted()
await sftp.rename(remotePart, remoteFinal)
pending = false
if (!abort.signal.aborted) res.status(201).json({ id })
} catch {
console.error(JSON.stringify({ event: 'export_failed', requestId: res.locals.requestId }))
fail(502, 'Export could not be confirmed')
} finally {
// A disconnected SSH session cannot guarantee deletion; the inbox janitor handles those parts.
if (connected && pending && !socket.destroyed) {
await sftp.delete(remotePart, true).catch(() => {
console.error(JSON.stringify({ event: 'cleanup_pending', requestId: res.locals.requestId }))
})
}
socket?.destroy()
await sftp.end().catch(() => {})
if (directory) await rm(directory, { recursive: true, force: true }).catch(() => {
console.error(JSON.stringify({ event: 'local_cleanup_failed', requestId: res.locals.requestId }))
})
clearTimeout(timer)
abort.signal.removeEventListener('abort', cancelSocket)
req.off('aborted', disconnect)
res.off('close', disconnect)
active -= 1
}
})
app.use(express.static(fileURLToPath(new URL('./public/', import.meta.url))))
app.use((_req, res) => res.status(404).json({ error: 'Not found' }))
app.use((_error, _req, res, _next) => {
if (!res.headersSent) res.status(500).json({ error: 'Request failed' })
})
const httpPort = Number(process.env.PORT ?? 3000)
if (!Number.isInteger(httpPort) || httpPort < 0 || httpPort > 65535) {
throw new Error('Invalid HTTP port')
}
const server = app.listen(httpPort, '127.0.0.1', (error) => {
if (error) {
console.error('Gateway could not bind its HTTP port: ' + error.code)
process.exitCode = 1
return
}
console.log('Open ' + APP_ORIGIN)
})
server.requestTimeout = 35_000
server.headersTimeout = 10_000
セキュリティ上の考慮事項
ローカルページはループバック上で HTTP を使用します。デプロイするページとゲートウェイには、HTTPS、設定と完全に一致する Origin、認可されたユーザーだけに
sftp:upload を割り当てる実際の ID プロバイダーが必要です。Origin の検証はトークン検証を補完するもので、呼び出し元の認証にはなりません。CORS は無効のままにします。
受信ディレクトリへの書き込み元は、信頼できる一つだけです。信頼できないプロセスが、その場所で /incoming の名前変更、シンボリックリンクの追加、ファイル作成との競合を起こせてはいけません。正規化されたパスの確認は、こうした権限制御の代わりにはなりません。ランダムな名前と排他的な一時ファイル作成により、送信されたファイル名の再利用を避けます。再試行のたびに新しい ID を作成します。
この単一プロセスは、同時に二つのリクエストを受け付けます。各リクエストのローカル一時保存は最大 5 MiB、転送期限は 30 秒です。どちらの転送もストリーミングで処理し、ファイル全体をメモリに保持しません。これらの制限は、一つのプロセス内で処理中のリクエストに適用されます。デモを応用する場合、転送完了済みのリモートファイルや、クラッシュまたは削除失敗で残ったローカルの一時ファイルには、別途ディスククォータとクリーンアップが必要です。
SSH セッションが切断されると、.part ファイルが残る場合があります。名前変更後に HTTP レスポンスが失われると、ブラウザーでは結果を確認できなくても、完全な .bin ファイルが残る場合があります。受領情報は名前変更の成功を確認するものであり、厳密に一度だけの配信プロトコルでも、永続性の保証でもありません。結果が不明な転送を再試行する前に、受信ディレクトリを確認してください。このデモを停止すると、使い捨ての受信ディレクトリ全体が削除されます。永続的なサービスでは、代わりに放置された一時ファイルの管理ポリシーが必要です。
ファイルエクスポート機能のテスト
四つのファイルをすべて保存したら、サーバーを準備してください。
node demo.mts setup
トークンを生成し、出力をコピーしてください。この端末は他人に見せないでください。トークンは有効期限までアップロード権限を付与します。新しいトークンが必要になったら、同じコマンドを再実行してください。
node demo.mts token
ゲートウェイをフォアグラウンドで起動してください。
node demo.mts serve
http://127.0.0.1:3000/ を開き、Your access token にトークンを貼り付け、ファイルを選んで Export to SFTP を選択してください。処理中は Exporting… と表示されます。HTTP 201 の後は、File exported. Receipt: に続いて ID が表示されます。file:// を開いた場合や、表示されたオリジンの代わりに
localhost を使った場合は動作しません。ポート 3000 が使用中なら、別のサービスを停止するか、PORT=3002 node demo.mts serve を使って、表示されたオリジンを開いてください。
別の端末で同じプロジェクトディレクトリに移動してください。RECEIPT_ID をその ID に、ORIGINAL_FILE を選択したファイルそのものに置き換えてください。このコマンドは Docker 経由で非公開のリモートファイルを独立して読み取り、元のファイルとバイト列を比較し、モードが 600 であることを確認します。
node demo.mts verify RECEIPT_ID ORIGINAL_FILE
七バイトの入力では、Verified 7 bytes; mode 600 と出力されます。空のファイルとバイナリファイルもテストしてください。トークン、発行者、スコープ、Origin の誤り、サイズ超過または中断されたボディ、ホスト鍵の固定値の誤り、リモート受信ディレクトリへの書き込み不可のいずれの場合も、最終ファイルが公開されてはいけません。アップロードのエラーレスポンスには、汎用メッセージとリクエスト ID だけを含め、SSH 認証情報や内部エラーの詳細は一切含めません。転送が拒否された場合や確認が失われた場合、ブラウザーには
Export could not be confirmed. Check your inbox before retrying.
と表示されます。
サーバーの端末で Ctrl+C を押し、シェルに戻ってください。その後、デモのサーバー、イメージ、受信ディレクトリ、認証情報を削除してください。削除されるのは、このプロジェクトのセットアップで記録したリソースだけです。
node demo.mts stop
まとめ
このフローを既存のアプリケーションに組み込む場合は、開発用の発行機能と使い捨てアカウントを置き換えてください。ブラウザーの認可境界と、信頼できるサーバー設定は維持してください。エクスポート前のファイル処理については、Transloadit の SFTP エクスポート Robotを参照してください。
ご自身での運用は避けたいですか?
Transloadit は、単一の API 呼び出し内の処理の一環として、S3、Azure、Google Cloud などにファイルをエクスポートします。
