Open burakkilic opened 10 years ago
I can't imagine how you expect us to be able to help you without posting some sample code.
Sorry about that:
var s3Client = knox.createClient({
key: '****',
secret: '********',
bucket: 'myBucket'
});
And my uploader function:
exports.upload = function(req, res) {
var form = new multiparty.Form();
var batch = new Batch();
batch.push(function(cb) {
form.on('field', function(name, value) {
if (name === 'path') {
var destPath = value;
if (destPath[0] !== '/') destPath = '/' + destPath;
cb(null, destPath);
}
});
});
batch.push(function(cb) {
form.on('part', function(part) {
if (!part.filename) return;
cb(null, part);
});
});
batch.end(function(err, results) {
if (err) throw err;
form.removeListener('close', onEnd);
var destPath = results[0],
part = results[1];
headers['Content-Length'] = part.byteCount;
s3Client.putStream(part, destPath, headers, function(err, s3Response) {
if (err) throw err;
res.statusCode = s3Response.statusCode;
s3Response.pipe(res);
console.log("https://s3.amazonaws.com/" + process.env.S3_BUCKET + destPath);
});
});
form.on('close', onEnd);
form.parse(req);
function onEnd() {
throw new Error("no uploaded file");
}
}
Nothing returns.
Hi;
My upload to S3 code was working yesterday but now I am getting
What can be the problem?