1
我試圖從字符串創建一個csv並將其上傳到我的S3存儲桶。我不想寫一個文件。我希望這一切都在記憶中。上傳文件流到S3沒有文件和內存
我不想從文件中讀取以獲取我的流。我想用文件創建一個流。我希望這種方法createReadStream
,但我想傳遞一個字符串與我的流的內容,而不是一個文件。
var AWS = require('aws-sdk'),
zlib = require('zlib'),
fs = require('fs');
s3Stream = require('s3-upload-stream')(new AWS.S3()),
// Set the client to be used for the upload.
AWS.config.loadFromPath('./config.json');
// Create the streams
var read = fs.createReadStream('/path/to/a/file');
var upload = s3Stream.upload({
"Bucket": "bucket-name",
"Key": "key-name"
});
// Handle errors.
upload.on('error', function (error) {
console.log(error);
});
upload.on('part', function (details) {
console.log(details);
});
upload.on('uploaded', function (details) {
console.log(details);
});
read.pipe(upload);