Upload image to S3 Amazon get 0 bytes
<p>I'm trying to upload image png/jpg <strong>less than 10 kilobytes</strong> to s3 amazon.
The upload succeed but the file uploaded and stored with 0 bytes.</p>

<p>When i'm trying to see the image in the link provided by s3- i get blank.</p>

<p>If i upload image more bigger than 10 kilobytes size it's ok.</p>

<p>Can someone have any idea what is the problem please?</p>

<pre><code>file_name = account[:img_token] + File.extname(img.original_filename)
file = Tempfile.new(file_name, encoding: 'ascii-8bit')
file.write(img.read)
path = file.path
bucket_name = 'bucket'
s3 = AWS::S3.new(access_key_id: ENV['S3_ACCESS_KEY'], secret_access_key: ENV['S3_SECRET_ACCESS_KEY'])
link = 'https://s3-eu-west-1.amazonaws.com/' + bucket_name + '/' + file_name
key = file_name
object = s3.buckets[bucket_name].objects[key].write(file: path, acl: 'public-read')
</code></pre>