File size: 631 Bytes
3d979b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * Amazon S3 client
 */
class S3 {
  /**
   * Upload file to S3
   * @param {string} fileID File ID of the image in Google Drive
   * @return {string} URL of the uploaded file
   */
  static uploadFile(fileID) {
    var file = DriveApp.getFileById(fileID);
    var blob = file.getBlob();
    var s3 = Aws.S3({
      accessKeyId: CONFIG.S3_ACCESS_KEY_ID,
      secretAccessKey: CONFIG.S3_SECRET_ACCESS_KEY,
      region: CONFIG.S3_REGION
    });
    var params = {
      Bucket: CONFIG.S3_BUCKET_NAME,
      Key: file.getName(),
      Body: blob
    };
    var data = s3.upload(params).promise();
    return data.Location;
  }
}