title: Size of file stored on the Amazon S3 bucket
body: <p>I have following model</p>
  <pre><code>class MediaFile(Media):
      s3_file = GenericFileField(tag=&quot;s3-tag&quot;, null=True, blank=True, max_length=300)
  </code></pre>
  <p>How can I get size of file stored on s3?</p>
  <p>I tried this, but it's not work.</p>
  <pre><code>    def file_size(self):
          try:
              prefix = get_file_key(self.s3_file)
              s3 = boto3.resource(&quot;s3&quot;)
              bucket = s3.Bucket()
              return bucket.Object(prefix).content_length
          except:
              pass
  </code></pre>