當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。