generators/aws-containers/aws-client.js
function uploadTemplate(bucketName, filename, path) {
    return spinner(
        new Promise((resolve, reject) =>
            fs.stat(path, (error, stats) => {
                if (!stats) {
                    reject(new Error(`File ${chalk.bold(path)} not found`));
                }
                const upload = s3.upload(
                    {
                        Bucket: bucketName,
                        Key: filename,
                        Body: fs.createReadStream(path)
                    },
                    {
                        partSize: Math.max(stats.size, S3_MIN_PART_SIZE),
                        queueSize: 1
                    }
                );
                let bar;
                upload.on('httpUploadProgress', evt => {
                    if (!bar && evt.total) {
                        const total = evt.total / 1000000;
                        bar = new ProgressBar('uploading [:bar] :percent :etas', {
                            complete: '=',
                            incomplete: ' ',
                            width: 20,
                            total,
                            clear: true
                        });
                    }

                    const curr = evt.loaded / 1000000;
                    bar.tick(curr - bar.curr);
                });
                return upload
                    .promise()
                    .then(resolve)
                    .catch(reject);
            })
        )
    );
}
function uploadTemplate(bucketName, filename, path) {
    return spinner(
        new Promise((resolve, reject) =>
            fs.stat(path, (error, stats) => {
                if (!stats) {
                    reject(new Error(`File ${chalk.bold(path)} not found`));
                }
                const upload = s3.upload(
                    {
                        Bucket: bucketName,
                        Key: filename,
                        Body: fs.createReadStream(path)
                    },
                    {
                        partSize: Math.max(stats.size, S3_MIN_PART_SIZE),
                        queueSize: 1
                    }
                );
                let bar;
                upload.on('httpUploadProgress', evt => {
                    if (!bar && evt.total) {
                        const total = evt.total / 1000000;
                        bar = new ProgressBar('uploading [:bar] :percent :etas', {
                            complete: '=',
                            incomplete: ' ',
                            width: 20,
                            total,
                            clear: true
                        });
                    }

                    const curr = evt.loaded / 1000000;
                    bar.tick(curr - bar.curr);
                });
                return upload
                    .promise()
                    .then(resolve)
                    .catch(reject);
            })
        )
    );
}
function uploadTemplate ( bucketName , filename , path ) { return spinner ( new Promise ( ( resolve , reject ) => fs . stat ( path , ( error , stats ) => { if ( ! stats ) { reject ( new Error ( ` ${ chalk . bold ( path ) } ` ) ) ; } const upload = s3 . upload ( { Bucket : bucketName , Key : filename , Body : fs . createReadStream ( path ) } , { partSize : Math . max ( stats . size , S3_MIN_PART_SIZE ) , queueSize : 1 } ) ; let bar ; upload . on ( 'httpUploadProgress' , evt => { if ( ! bar && evt . total ) { const total = evt . total / 1000000 ; bar = new ProgressBar ( 'uploading [:bar] :percent :etas' , { complete : '=' , incomplete : ' ' , width : 20 , total , clear : true } ) ; } const curr = evt . loaded / 1000000 ; bar . tick ( curr - bar . curr ) ; } ) ; return upload . promise ( ) . then ( resolve ) . catch ( reject ) ; } ) ) ) ; }
Upload the template in the S3Bucket
@param bucketName S3 Bucket name to upload the template into
@param filename Name to give to the file in the Bucket
@param path Path to the file
@returns {Promise}
Upload the template in the S3Bucket