Created
August 1, 2021 12:06
-
-
Save anna-geller/5644de2c962f30c5d86ea3ab91b3a486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
s3 = boto3.client("s3") | |
bucket_name = "annageller" | |
s3_object = "sales/customers.csv" | |
local_file_path = f"/Users/annageller/Desktop/datasets/{s3_object}" | |
# Uploading without specifying content type | |
s3.upload_file( | |
local_file_path, | |
bucket_name, | |
s3_object | |
) | |
response = s3.head_object(Bucket=bucket_name, Key=s3_object) | |
print(response["ResponseMetadata"]["HTTPHeaders"]["content-type"]) # binary/octet-stream | |
# Uploading with specifying content type: text/csv | |
s3.upload_file( | |
local_file_path, | |
bucket_name, | |
s3_object, | |
ExtraArgs={'ContentType': 'text/csv'} | |
) | |
response = s3.head_object(Bucket=bucket_name, Key=s3_object) | |
print(response["ResponseMetadata"]["HTTPHeaders"]["content-type"]) # text/csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment