Skip to content

Commit

Permalink
Fix the nmdb CSV export by calling getvalue() (#6064)
Browse files Browse the repository at this point in the history
Not sure why this cropped up now, but along the way we lost the ability
to feed a bare file object to boto3 for uploading to S3. Boto creates and
md5 hash of the content and expects bytes in making the hash, and
our previous code delivered unicode.

The solution is to pass the bytes instead of the file object to boto,
by calling `getvalue()` on the file object.
  • Loading branch information
higs4281 committed Oct 7, 2020
1 parent f208b54 commit 83315fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cfgov/data_research/mortgage_utilities/s3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def bake_csv_to_s3(slug, csv_file_obj, sub_bucket=None):
Key='{}/{}.csv'.format(sub_bucket, slug),
ACL='public-read',
ContentType='text/csv',
Body=csv_file_obj,
Body=csv_file_obj.getvalue(),
CacheControl='max-age=2592000,public',
Expires=expires
)

0 comments on commit 83315fc

Please sign in to comment.