I need to define an ACL in my current setting when I write on S3, otherwise the file will end up with no permissions (nobody can read it). How can I do that with smart_open?
Please note that I cannot pass it as a kwarg, as the following line will fail:
session = kwargs.pop(
's3_session',
boto3.Session(profile_name=kwargs.pop('profile_name', None))
)
> s3 = session.resource('s3', **kwargs)
E TypeError: resource() got an unexpected keyword argument 'ACL'
One hacky solution here is to call the s3 implementation directly:
smart_open.smart_open_s3.open(s3_bucket, s3_key, 'wb', **{
's3_session': boto_session,
'ACL': 'bucket-owner-full-control',
})
This works:
with smart_open.open(
s3_path, 'w', transport_params={'session': session, 'multipart_upload_kwargs': {'ACL': 'bucket-owner-full-control'}}) as out_file:
out_file.write(...)
Most helpful comment
This works: