I was wondering, since an upload stream passes through the server's buffer and than passed from the server to S3, am I actually uploading the file "twice".
First time I load (or stream) the file to the local server and than from the server to the cloud? Is there a way to skip the middle man and pass the files straight to S3?
Here's the code I'm using:
config.allowedContent = {
$1: {
// Use the ability to specify elements as an object.
elements: CKEDITOR.dtd,
attributes: true,
styles: true,
classes: true
}
};
config.disallowedContent = 'img{width,height}';
When I render 'upload' on the get request, this is the client side code:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
var zlib = require('zlib');
var multipart = require('connect-multiparty')
module.exports = function (router) {
router.get('/', function (req,res) {
res.render('upload')
})
router.post('/',multipart(), function (req,res) {
var body = fs.createReadStream(req.files.file.path).pipe(zlib.createGzip());
var s3obj = new AWS.S3({params: {Bucket: 'bucketName', Key: 'aFileName.ext'}});
s3obj.upload({Body: body}).
on('httpUploadProgress', function(evt) { console.log(evt); }).
send(function(err, data) { console.log(err, data) });
})
}
Am I going through my own server or am I uploading directly from the client?