You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thank you for this awesome package, it saved us lots of effort implementing S3 in reaction-files.
Multipart upload is great for large uploads but not so much for small files so for anyone looking for how to implement normal upload it here's the code:
async_getWriteStream(fileKey,options={}){constopts={Bucket: Meteor.settings.s3.bucket,Key: `${Date.now()}-${fileKey.filename}`};debug("S3Store _getWriteStream opts:",opts);debug("S3Store _getWriteStream options:",options);debug("S3Store _getWriteStream fileKey:",fileKey);debug("S3Store _getWriteStream objectACL",this.objectACL);letwriteStream;lettotalFileSize=0;letchunks=[];writeStream=newWritable({write: async(chunk,encoding,callback)=>{totalFileSize+=chunk.length;chunks.push(chunk);callback();}});writeStream.on("finish",async()=>{debug("S3Store writeStream finish");letuploadedFile=awaitthis.s3.upload({
...opts,Body: Buffer.concat(chunks),}).promise();debug("S3 multipart upload completed",uploadedFile);// Emit end and return the fileKey, size, and updated datewriteStream.emit("stored",{// Set the generated _id so that we know it for future reads and writes.// We store the _id as a string and only convert to ObjectID right before// reading, writing, or deleting.fileKey: uploadedFile.Key,storedAt: newDate(),size: totalFileSize});});returnwriteStream;}
The text was updated successfully, but these errors were encountered:
First, thank you for this awesome package, it saved us lots of effort implementing S3 in reaction-files.
Multipart upload is great for large uploads but not so much for small files so for anyone looking for how to implement normal upload it here's the code:
The text was updated successfully, but these errors were encountered: