convert code from boto to bot3
<p>I have a code which uploads base64 image to amazon s3 using boto version 2.38.0</p>

<pre><code>conn = boto.connect_s3(AWS_ACCESS_KEYXXX, AWS_SECRET_KEYXXX)

bucket = conn.get_bucket(AWS_BUCKET_NAMEXXX)

k = Key(bucket)

k.key = s3_file_name

k.set_metadata('Content-Type', 'image/jpeg')

k.set_contents_from_file(&lt;binary data of image base 64&gt;)
</code></pre>

<p>I want to convert this code so that it works for boto3 version as well.</p>

<pre><code>s3 = boto3.resource('s3')

res = s3.Object('&lt;bucket name&gt;', key_name).put(Body=binary_data, Metadata={'Content-Type': 'image/png'})

print "res : ", res
</code></pre>

<p>How can I generate image public url from this ? </p>

<p>Can any one please help me out with this ?</p>

<p>In order to generate public URL you can use following code</p>

<pre><code>k.set_acl('public-read')             # make file public
url = k.generate_url(expires_in=0, query_auth=False)  
</code></pre>

<p>If you want to generate temporary link then you can change expires_in parameter    </p>

<p><strong>Hope it helps !!</strong></p>

python boto boto3