0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

APIGateway経由でS3にuploadした画像が表示できない。

Last updated at Posted at 2021-07-07

isuue

前提
・RESTAPI
・アップストリームとの通信はHTTP。

以下のような流れでuploadした画像のurlを開くと、画像が表示されるはずが、なぜかダウンロードされてしまう。。。

  1. ブラウザのformから、Content-Type:multipart/form-data で画像やその他テキストを送信。 

  2. 画像は、 以下の流れでS3にアップロードされる。
    APIGateway → APサーバー → S3

解決方法

・設定からバイナリメディアタイプに、multipart/form-dataを設定する。

APIGatewayは、以下のように
ブラウザなどのクライアントからリクエストを受け取り
それを解釈してルーティング先のapサーバーにリクエストを送りなおしている。

・ クライアント http→  APIGateway http→ APサーバ

この際にAPIGatewayでは、
バイナリファイルとして認識すると明示していないContent-Typeに関しては、
テキストなどと同じように処理してしまうため、今回のようなことが起きてしまっていたよう。

バイナリメディアタイプに、明示的に指定してあげれば問題なく登録できるようになる。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?