ファイルダウンロード
生成されたPDFファイルをダウンロードするためのエンドポイントです。
ZIP一括ダウンロード
エンドポイント情報
- URL:
https://api.re-port-flow.com/v1/file/download/{requestId} - メソッド:
GET - 認証: アプリケーションキー(
appkeyヘッダー)が必要
レスポンス (200 OK)
レスポンスボディ: ZIPファイル(バイナリ)
| ヘッダー | 説明 | 例 |
|---|---|---|
Content-Type | コンテンツタイプ | application/zip |
Content-Length | ファイルサイズ(バイト) | 307200 |
Content-Disposition | ファイル名 | attachment; filename="files.zip" |
使用例
cURL
curl -X GET https://api.re-port-flow.com/v1/file/download/550e8400-e29b-41d4-a716-446655440000 \\
-H "appkey: your-app-key" \\
--output files.zip
JavaScript
async function downloadZip(requestId) {
const response = await axios.get(
`https://api.re-port-flow.com/v1/file/download/${requestId}`,
{
headers: { 'appkey': process.env.APP_KEY },
responseType: 'arraybuffer'
}
);
fs.writeFileSync('files.zip', response.data);
return response.data;
}
個別ファイルダウンロード
エンドポイント情報
- URL:
https://api.re-port-flow.com/v1/file/download/{requestId}/{fileId} - メソッド:
GET - 認証: アプリケーションキー(
appkeyヘッダー)が必要
レスポンス (200 OK)
レスポンスボディ: PDFファイル(バイナリ)
| ヘッダー | 説明 | 例 |
|---|---|---|
Content-Type | コンテンツタイプ | application/pdf |
Content-Length | ファイルサイズ(バイト) | 102400 |
Content-Disposition | ファイル名 | attachment; filename="invoice.pdf" |
File-ID | ファイルID | 7f3d1a2b-4c5e-6f7a-8b9c-0d1e2f3a4b5c |
使用例
cURL
curl -X GET https://api.re-port-flow.com/v1/file/download/550e8400-e29b-41d4-a716-446655440000/7f3d1a2b-4c5e-6f7a-8b9c-0d1e2f3a4b5c \\
-H "appkey: your-app-key" \\
--output invoice.pdf
JavaScript
async function downloadFile(requestId, fileId) {
const response = await axios.get(
`https://api.re-port-flow.com/v1/file/download/${requestId}/${fileId}`,
{
headers: { 'appkey': process.env.APP_KEY },
responseType: 'arraybuffer'
}
);
const returnedFileId = response.headers['file-id'];
console.log('ダウンロードしたファイルID:', returnedFileId);
return response.data;
}
エラーレスポンス
404 Not Found
{
"statusCode": 404,
"message": "File not found",
"error": "Not Found"
}
原因:
- 指定された
requestIdまたはfileIdが存在しない - ファイルの有効期限が切れた
対処法:
requestId/fileIdが正しいことを確認- ファイル生成から時間が経過している場合は再生成
ユースケース
ZIP内の特定ファイルのみダウンロード
// async/multiple のレスポンスから requestId と files を取得済みとする
async function downloadSpecificFile(requestId, files) {
const targetFile = files.find(f => f.fileName === 'invoice_001.pdf');
if (targetFile) {
const pdfData = await downloadFile(requestId, targetFile.fileId);
fs.writeFileSync('invoice_001.pdf', pdfData);
}
}