将响应主体中的zip文件从expressjs / nodejs发送到浏览器

我在后端使用expressjs和node,我需要允许前端用户下载文件。为此,我正在考虑使用诸如Minio和s3之类的对象存储,并使用它来创建对象并将文件url发送回前端,甚至我得到的代码都非常简单而甜美:

minioClient.makeBucket(bucketName,'us-east-1',function(err) {
if (err) return console.log(err)

console.log('Bucket created successfully in "us-east-1".')

var metaData = {
    'Content-Type': 'application/octet-stream','X-Amz-Meta-Testing': 1234,'example': 5678
}
// Using fPutObject API upload your file to the bucket europetrip.
minioClient.fPutObject(bucketName,fileName,filePath,metaData,function(err,etag) {
  if (err) return console.log(err)
  console.log('File uploaded successfully.')
  // expires in a day.
    minioClient.presignedGetObject(bucketName,24*60*60,presignedUrl) {
        if (err) return console.log(err)
        console.log(presignedUrl)
 })
   });
 });

但是由于基础架构的限制,我唯一的方法是创建一个zip文件并将该zip文件发送到用户浏览器,而不是存储它。 但是我不确定它是否完全可以在expressjs中使用?有人可以帮我吗?有没有可以用来将zip文件发送到客户端的简单库?

maoyink 回答:将响应主体中的zip文件从expressjs / nodejs发送到浏览器

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2689080.html

大家都在问