Convert byte[] to Base64 string for data URI

后端 未结 5 1545
名媛妹妹
名媛妹妹 2020-12-02 16:55

I know this has probably been asked 10000 times, however, I can\'t seem to find a straight answer to the question.

I have a LOB stored in my db that represents an i

5条回答
  •  [愿得一人]
    2020-12-02 17:48

    If you don't want to stream from a servlet, then save the file to a directory in the webroot and then create the src pointing to that location. That way the web server does the work of serving the file. If you are feeling particularly clever, you can check for an existing file by timestamp/inode/crc32 and only write it out if it has changed in the DB which can give you a performance boost. This file method also will automatically support ETag and if-modified-since headers so that the browser can cache the file properly.

提交回复
热议问题