简体   繁体   English

AWS小部件与Angular6的集成

[英]AWS widget integration with Angular6

I am working on Angular 6 application where in one my feature I have files listed in grid. 我正在使用Angular 6应用程序,其中我的一项功能是在网格中列出文件。 I want to provide facility to user to upload these files to AWS/Google Drive/Dropbox. 我想为用户提供将这些文件上传到AWS / Google Drive / Dropbox的便利。 Are there any useful blogs for same or anybody worked on similar functionality? 是否有适用于相同功能或相似功能的人有用的博客?

Please read this blog Angular 5 File Uploads to S3 with (relative ) ease https://medium.com/@bevin.hernandez/angular-5-file-uploads-to-s3-with-relative-ease-ea19b7fd120e 请阅读此博客(相对)轻松将Angular 5文件上传到S3 https://medium.com/@bevin.hernandez/angular-5-file-uploads-to-s3-with-relative-ease-ea19b7fd120e

fileEvent(fileInput: any) {
  const AWSService = AWS;
  const region = '<insert your region here>';
  const bucketName = '<insert your bucket name>';
  const IdentityPoolId = '<insert your identity pool id>';
  const file = fileInput.target.files[0];

// Configures the AWS service and initial authorization
  AWSService.config.update({
    region: region,
    credentials: new AWSService.CognitoIdentityCredentials({
      IdentityPoolId: IdentityPoolId
    })
  });

// adds the S3 service, make sure the api version and bucket are correct
  const s3 = new AWSService.S3({
    apiVersion: '2006-03-01',
    params: { Bucket: bucketName}
  });

// I store this in a variable for retrieval later
  this.image = file.name;
  s3.upload({ Key: file.name, Bucket: bucketName, Body: file, ACL: 'public-read'},
    function (err, data) { 
        if (err) { 
            console.log(err, 'there was an error uploading your file'); 
        }
 });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM