当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript s3.createClient函数代码示例

本文整理汇总了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();
    });
  });
})
开发者ID:aggarwalankush,项目名称:ionic,代码行数:32,代码来源:demos.prod.ts

示例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);
  });
}
开发者ID:academey,项目名称:coinone_dev_interview,代码行数:33,代码来源:pushToS3.ts

示例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);
        }
      });
    });
开发者ID:academey,项目名称:coinone_dev_interview,代码行数:19,代码来源:copyJsToRoot.ts

示例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();
    });
  });
}
开发者ID:aggarwalankush,项目名称:ionic,代码行数:38,代码来源:demos.prod.ts


注:本文中的s3.createClient函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。