I'm trying to upload image png/jpg less than 10 kilobytes to s3 amazon. The upload succeed but the file uploaded and stored with 0 bytes.
When i'm trying to see the image in the link provided by s3- i get blank.
If i upload image more bigger than 10 kilobytes size it's ok.
Can someone have any idea what is the problem please?
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')