DEV Community

Santhosh Thomas
Santhosh Thomas

Posted on

Flask Upload Image Directly To S3 Without Saving In Server

import boto3 s3 = boto3.client( "s3", aws_access_key_id= "*************", aws_secret_access_key="**********" ) @login_blueprint.route('/uploadfile', methods=['POST']) file= request.files['file'] try: filename = secure_filename(file.filename) acl="public-read" s3.upload_fileobj( file, 'bucket-name', file.filename, ExtraArgs={ "ACL": acl, "ContentType": file.content_type } ) except Exception as e: resp = jsonify(e) resp.status_code =200 return resp 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)