Created
November 28, 2019 09:45
-
-
Save nyawach/23006246971a6939f1a14b1aece6c24e to your computer and use it in GitHub Desktop.
やることとしてはこんな感じ
Lambda 以外でもできる - header の + `Content-Type` に `application/force-download` を追加 + `Content-disposition` に `attachment; filename=<ダウンロード時のファイル名>` を追加
- レスポンスボディに保存したいデータを記述
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { APIGatewayProxyHandler } from "aws-lambda" | |
export const handler: APIGatewayProxyHandler = async event => { | |
const filename = "data.json" | |
return { | |
statusCode: 200, | |
headers: { | |
"Content-Type": "application/force-download", | |
"Content-disposition": `attachment; filename=${filename}`, | |
}, | |
body: JSON.stringify({ | |
"id": 1, | |
"name": "test-user", | |
}), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment