title: TypeError: Cannot read property 'byteLength' of undefined - AWS S3 Upload
body: <p>I'm working on an aws s3 photo upload from a react client and I'm experiencing the following error:</p>
  <p><code>TypeError: Cannot read property 'byteLength' of undefined</code></p>
  <p>I'm assuming there's a flaw in the upload object, but I believe there might be something wrong with the s3/cognito configuration because I receive the same error when I invoked <code>s3.listObjects</code>. I'm following these docs - <a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album-full.html" rel="noreferrer">https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album-full.html</a></p>
  <p>Any thoughts?</p>
  <pre><code>uploadPhoto() {
          const files = document.getElementById(&quot;photoUpload&quot;).files;
          if (!files.length) {
            return alert(&quot;Please choose a file to upload first.&quot;);
          }
          const file = files[0];
          const fileName = file.name;
          const albumPhotosKey = encodeURIComponent('screenshots') + &quot;/&quot;;
        
          const photoKey = albumPhotosKey + fileName;
          
          // Use S3 ManagedUpload class as it supports multipart uploads
          
          const upload = new AWS.S3.ManagedUpload({
              params: {
                Bucket: &lt;Bucket Name&gt;,
                Key: fileName,
                Body: file
              }
            });
  
          const promise = upload.promise();
        
          promise.then(
            function(data) {
              alert(&quot;Successfully uploaded photo.&quot;);
              console.log('UPLOAD: ', data)
            },
            function(err) {
                console.log('ERROR: ', err)
              // return alert(&quot;There was an error uploading your photo: &quot;, err.message);
            }
          );
        }
  </code></pre>