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


TypeScript S3.upload方法代码示例

本文整理汇总了TypeScript中aws-sdk.S3.upload方法的典型用法代码示例。如果您正苦于以下问题:TypeScript S3.upload方法的具体用法?TypeScript S3.upload怎么用?TypeScript S3.upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aws-sdk.S3的用法示例。


在下文中一共展示了S3.upload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: uploadFileToS3

  /**
  * Helper function upload file to s3
  * @param {any} bodyStream - binary64 for file
  * @param {string} filename
  * @method uploadFileToS3
  */
 public static async uploadFileToS3(bodyStream: any, filename: string) {
   console.log('upload to s3');
   const fileKey = `${uuid.v4()}_${filename}.pdf`;
   const response = await s3.upload({
     Key: fileKey.replace(/\s+/g, ''),
     Body: bodyStream,
     ACL: 'private'
   }).promise();
   return response;
 }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例2: Promise

 return new Promise((resolve, reject) => {
   s3.upload({ Body: JSON.stringify(manifest), Bucket: this.registryBucket, Key: id}, (err, res) => {
     if (err) return reject(err);
     resolve(res);
   })
 });
开发者ID:tbtimes,项目名称:lede-cli,代码行数:6,代码来源:default.fetcher.ts

示例3: main

async function main() {
  const tData = await axios.get(
    'https://api.github.com/repos/prisma/prisma/releases'
  );
  const stableReleaseVersion = tData.data.filter(
    node => !node.tag_name.includes('alpha') && !node.tag_name.includes('beta')
  )[0].tag_name;
  console.log(`Version to publish: ${stableReleaseVersion}`);

  console.log('Creating binary');
  const buildResponse = spawnSync('npm', ['run', 'make-binary']);
  console.log(`Created binary.... ${buildResponse.stdout.toString()}`);

  const tarFileName = `prisma-${stableReleaseVersion}.tar.gz`;
  const tarResponse = spawnSync('tar', ['-cvzf', tarFileName, 'prisma']);
  console.log('made tar', tarResponse.stdout.toString());
  const shaResponse = spawnSync('shasum', ['-a', '256', tarFileName]);
  const shaValue = shaResponse.stdout
    .toString()
    .split(' ')[0]
    .trim();
  console.log(`shasum -a 256 ${tarFileName} => ${shaValue}`);

  console.log('Uploading tar to S3....this may take a while');

  const fileData = await fs.readFile(tarFileName);
  const s3 = new AWS.S3({ params: { timeout: 6000000 } });

  const s3Resp = await s3
    .upload({
      Bucket: 'homebrew-prisma',
      Key: tarFileName,
      Body: fileData,
      ACL: 'public-read'
    })
    .promise();
  console.log('Tar uploaded at location', s3Resp.Location);

  const uploadedBinaryURL = s3Resp.Location;
  console.log(`uploaded binary url ${uploadedBinaryURL}`);
  let homebrewDefinition = ``;
  const homeBrewTmp = `
class Prisma < Formula
  desc "Prisma turns your database into a realtime GraphQL API"
  homepage "https://github.com/prisma/prisma"
  url "https://s3-eu-west-1.amazonaws.com/homebrew-prisma/prisma-1.22.0.patch.1.tar.gz"
  sha256 "052cc310ab3eae8277e4d6fbf4848bc5c518af8e5165217a384bc26df82e63b9"
  version "1.22.0.patch.1"

  bottle :unneeded

  def install
    bin.install "prisma"
  end
end
  `;
  homeBrewTmp.split(/\r?\n/).forEach(line => {
    if (line.includes('version')) {
      homebrewDefinition += `  version "${stableReleaseVersion}"${os.EOL}`;
    } else if (line.includes('url')) {
      homebrewDefinition += `  url "${uploadedBinaryURL}"${os.EOL}`;
    } else if (line.includes('sha256')) {
      homebrewDefinition += `  sha256 "${shaValue}"${os.EOL}`;
    } else {
      homebrewDefinition += `${line}${os.EOL}`;
    }
  });

  await gitCommitPush({
    owner: 'prisma',
    repo: 'homebrew-prisma',
    token,
    files: [{ path: 'prisma.rb', content: homebrewDefinition }],
    fullyQualifiedRef: 'heads/automated-pr-branch',
    commitMessage: `bump version to ${stableReleaseVersion}`
  });

  const pullRes = await axios.post(
    'https://api.github.com/repos/prisma/homebrew-prisma/pulls',
    {
      title: `Automated PR for version ${stableReleaseVersion}`,
      head: 'automated-pr-branch',
      base: 'master',
      body: ' Automated PR generated via script',
      maintainer_can_modify: true
    }
  );
  console.log(
    `Pull Request created at ${
      pullRes.data.html_url
    }. Merge this to complete the release`
  );
}
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:93,代码来源:release-brew.ts


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