本文整理汇总了TypeScript中s3.createClient函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createClient函数的具体用法?TypeScript createClient怎么用?TypeScript createClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createClient函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: task
task('demos.download', (done: Function) => {
if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
return new Promise((resolve) => {resolve();});
}
let client = s3.createClient({
s3Options: {
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET
},
});
let params = {
localDir: join(process.cwd(), 'dist', 'demos', 'src'),
s3Params: {
Bucket: "ionic-demos",
},
};
let uploader = client.downloadDir(params);
return new Promise((resolve, reject) => {
uploader.on('error', function(err) {
console.error("s3 Download Error:", err.stack);
reject();
});
uploader.on('end', function() {
console.log("Demos downloaded from s3");
resolve();
});
});
})
示例2: pushToS3
export default function pushToS3(NEW_TAG: string) {
console.log("Start to upload bundled javascript files to S3");
const s3Client = s3.createClient(DeployConfig.S3_CLIENT_OPTIONS);
let uploader: DeployConfig.IS3ClientUploaderOptions;
return new Promise((resolve, reject) => {
uploader = s3Client.uploadDir({
localDir: DeployConfig.APP_DEST,
s3Params: {
Bucket: DeployConfig.AWS_S3_BUCKET,
Prefix: `${DeployConfig.AWS_S3_FOLDER_PREFIX}/${NEW_TAG}`,
CacheControl: "public, max-age=604800",
ACL: "public-read",
},
});
uploader.on("error", (err: Error) => {
console.error("unable to sync:", err.stack);
reject(err);
});
uploader.on("progress", () => {
console.log("progress", uploader.progressAmount, uploader.progressTotal);
});
uploader.on("end", () => {
console.log("END to upload dist files to S3");
resolve();
});
}).catch(err => {
console.error(err);
});
}
示例3: Promise
return new Promise((resolve, reject) => {
const s3Client = s3.createClient(DeployConfig.S3_CLIENT_OPTIONS);
const params = {
Bucket: DeployConfig.AWS_S3_BUCKET,
CopySource: `${DeployConfig.AWS_S3_BUCKET}/${DeployConfig.AWS_S3_FOLDER_PREFIX}/${NEW_TAG}/bundle.js`,
Key: "bundle.js",
ACL: "public-read",
};
s3Client.copyObject(params, (err: Error, res: any) => {
if (err) {
console.error("copy to root has failed!", err);
reject(err);
} else {
resolve(res);
}
});
});
示例4: uploadToS3
function uploadToS3(path) {
// fail silently if envars not present
if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
return new Promise((resolve) => {resolve();});
}
let client = s3.createClient({
s3Options: {
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET
},
});
// get demo name from path
let demo = path.split('/')[path.split('/').length - 2];
let params = {
localDir: path.replace('tsconfig.json',''),
deleteRemoved: true,
s3Params: {
Bucket: "ionic-demos",
Prefix: demo,
},
};
var uploader = client.uploadDir(params);
return new Promise((resolve, reject) => {
uploader.on('error', function(err) {
console.error("s3 Upload Error:", err.stack);
reject();
});
uploader.on('end', function() {
console.log(demo, " demo uploaded to s3");
resolve();
});
});
}