Python/Python Programming

[ Python ] mp4 url 다운로드 후 다이렉트 S3 저장

Pydole 2023. 5. 25. 14:27

 

import requests as req
import boto3

s3 = boto3.client('s3')

def mp4_save_s3():
    url = 'url'                # mp4 download url
    key = 'test.mp4'
    bucket = 'bucketname'      # bucketname
    
    res = req.get(url)
    res = s3.put_object(Bucket=bucket, Body=res.content, Key=key)
    
    return res['ResponseMetadata']['HTTPStatusCode']

mp4_save_s3()

-------------------------------------------------------------

200