title: create sub folders while uploading files to Amazon S3
body: <p>Previously, I was uploading files to Amazon S3 like this and it worked fine:</p>
  <pre><code>bucket.upload_fileobj(
              io.BytesIO(gzipped_content),
              fileName2,
              ExtraArgs={&quot;ContentType&quot;: &quot;text/plain&quot;})
  </code></pre>
  <p>In this case, fileName2 was placed directly into the bucket's root folder. Now I want to place fileName2 in sub folders. Like this: <code>bucket/year/month/day/fileName2</code>. I have variables year/month/day saved as strings with me. I tried this:</p>
  <pre><code>bucket.upload_fileobj(
              io.BytesIO(gzipped_content),
              year/month/day/fileName2,
              ExtraArgs={&quot;ContentType&quot;: &quot;text/plain&quot;})
  </code></pre>
  <p>but this throws an error that: <code>unsupported operand type(s) for /: 'str' and 'str'</code>. I also tried this:</p>
  <pre><code>path = year + month + day + fileName2
  bucket.upload_fileobj(
              io.BytesIO(gzipped_content),
              path,
              ExtraArgs={&quot;ContentType&quot;: &quot;text/plain&quot;})
  </code></pre>
  <p>but in this case, the path appears as the full filename. Instead of sub-folders. How can I use variables to upload files into subfolders? I can't hard code because I will need to run the function in a loop</p>