jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
4k stars 415 forks source link

Do I need to use mitm? #341

Open ZainChenDev opened 6 months ago

ZainChenDev commented 6 months ago

I've recently been trying to use Streamsaver.js to transfer file streams from my own server to the frontend browser. I've successfully set the Content-Disposition and Content-Type, where Content-Type is determined to be application/octet-stream. this is my code on my (springboot) server:

public void getMinioObject(String bucket, String objectKey, HttpServletResponse response)  {
    StatObjectResponse stat = minioClient.statObject(
        StatObjectArgs.builder()
            .bucket(bucket)
            .object(objectKey)
            .build()
    );
    response.setContentType(stat.contentType());
    response.setCharacterEncoding("UTF-8");
    response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(objectKey, "UTF-8"));

    InputStream is = minioClient.getObject(GetObjectArgs.builder().bucket(bucket).object(objectKey).build());
    IOUtils.copy(is, response.getOutputStream());
    is.close();
}

I would like to know if it's still necessary to use mitm? Now I have my own MitM installed on my server, but a popup appears when downloading files. I'm not sure if I need to use MitM and how to close this popup.