Louie NRT Story

[AWS] Lambda for S3 본문

서버시스템

[AWS] Lambda for S3

hyeok0724.kim@gmail.com 2019. 1. 6. 00:15
반응형

Download file from S3 and upload this again.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import boto3
import os
import sys
import urllib
 
s3_client = boto3.client('s3')
 
def handler(event, context):
    bucket = 'codebuild-oregon-louie0724-output-bucket'
    key = 'test01.png'
    raw_key = urllib.parse.unquote_plus(key)
    download_path = '/tmp/{}'.format(key)
    upload_path = '/tmp/{}'.format(key)
 
    s3_client.download_file(bucket, raw_key, download_path)
 
    s3_client.upload_file(upload_path, bucket, 'thumbnail-{}'.format(raw_key))
 
    print("success Upload")
 
cs


More Simple programming.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import boto3
import os
import sys
import urllib
 
s3_client = boto3.client('s3')
 
def handler(event, context):
    bucket = 'codebuild-oregon-louie0724-output-bucket'
    key = 'test01.png'
    #raw_key = urllib.parse.unquote_plus(key)
    download_path = '/tmp/test01.png'
    upload_path = '/tmp/test01.png'
 
    s3_client.download_file(bucket, key, download_path)
 
    s3_client.upload_file(upload_path, bucket, 'thumbnail-test01.png')
 
cs


[reference] https://www.qwiklabs.com

반응형

'서버시스템' 카테고리의 다른 글

[Cloud_Class] 190108_EMR(Hadoop)  (0) 2019.01.09
[Cloud_Class] 190104 Githook  (0) 2019.01.09
[AWS] Lambda programming for DynamoDB  (0) 2019.01.06
[AWS] Quick Starts  (0) 2019.01.04
[Cloud_Class] 190103 Elastic Beanstalk  (0) 2019.01.04
Comments