s3Service_2.py 914 B

1234567891011121314151617181920
  1. def upload_file_tos3(self,bucket_name,file_name,file_content):
  2. """Methof to upload file to s3.
  3. Parameters
  4. ----------
  5. bucket_name : string
  6. Name of the bucket, where the file need to be uploaded.
  7. file_name : string
  8. file which need to be uploaded to bucket
  9. file_content: json
  10. The content which is being uploaded to s3 with it's name as file_name
  11. """
  12. s3 = boto3.client("s3")
  13. s3_file_path = cf.constants['s3_folder_path']
  14. #s3.put_object is the method provided by boto3 to upload file.
  15. response_upload_object = s3.put_object(Bucket=bucket_name, Key=s3_file_path+file_name,Body=file_content)
  16. print("The response upload object is",response_upload_object)
  17. # #print("The extension of the file is ",magic.from_file(fileContent, mime = True))
  18. return response_upload_object