【发布时间】:2015-09-30 18:07:57
【问题描述】:
我关注this example
// Load the stream
var fs = require('fs'), zlib = require('zlib');
var body = fs.createReadStream('bigfile').pipe(zlib.createGzip());
// Upload the stream
var s3obj = new AWS.S3({params: {Bucket: 'myBucket', Key: 'myKey'}});
s3obj.upload({Body: body}, function(err, data) {
if (err) console.log("An error occurred", err);
console.log("Uploaded the file at", data.Location);
})
而且它“工作”的原因在于它完全按照预期执行所有操作,除了文件到达 S3 压缩并保持这种方式。
据我所知,在 S3 上没有自动解压缩的功能,因此,如果您的意图是上传公开可用的图像或视频(或最终用户打算简单消费的任何其他内容),则解决方案似乎让上传的文件像这样解压缩......
// Load the stream
var fs = require('fs'), zlib = require('zlib');
var body = fs.createReadStream('bigfile');//.pipe(zlib.createGzip()); <-- removing the zipping part
// Upload the stream
var s3obj = new AWS.S3({params: {Bucket: 'myBucket', Key: 'myKey'}});
s3obj.upload({Body: body}, function(err, data) {
if (err) console.log("An error occurred", err);
console.log("Uploaded the file at", data.Location);
})
我很好奇我是否做错了什么,是否有一种自动方法让 S3 识别到文件正在压缩并解压缩?
【问题讨论】:
标签: node.js amazon-web-services amazon-s3 gzip