tools_1.py 447 B

12345678910111213141516171819
  1. def upload_file_to_s3(file, bucket_name, acl="public-read"):
  2. try:
  3. s3.upload_fileobj(
  4. file,
  5. bucket_name,
  6. file.filename,
  7. ExtraArgs={
  8. "ACL": acl,
  9. "ContentType": file.content_type
  10. }
  11. )
  12. except Exception as e:
  13. print("Something Happened: ", e)
  14. return e
  15. return "{}{}".format(app.config["S3_LOCATION"], file.filename)