Spaces:
Running
on
Zero
Running
on
Zero
/** | |
* 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; | |
} | |
} |