title: After uploading image to s3, upload accompanying thumbnail
body: <p>I can successfully upload my images to s3 via AJAX. However I need to have an accompanying  thumbnail in my s3 bucket as well. </p>
  
  <p>Here's my s3 upload ajax view:</p>
  
  <pre><code>...
  session = boto3.Session(
      aws_access_key_id=AWS_ACCESS_KEY_ID,
      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
  )
  s3 = session.resource('s3')
  
  s3.Bucket('****-bucket').put_object(Key='media/%s' % random_filename, Body=img, ContentType='image/png')
  return HttpResponse()
  </code></pre>
  
  <p>What is the best way to create and upload a thumbnail from my code? Do I add another <code>put_object</code> under my current one? If so, how do I implement a thumbnail generator like PIL? I tried to replicate <a href="https://stackoverflow.com/questions/36274868/saving-an-image-to-bytes-and-uploading-to-boto3-returning-content-md5-mismatch">this answer</a> however the setup is quite different to mine. </p>
  
  <p>Or is it viable to use a AWS lambda function instead?</p>
  
  <p>Any advice appreciated.</p>
  
  <p>EDIT:</p>
  
  <p>Files can be uploaded via 2 methods: image from disk and image from URL. The filename is taken from a random string generated in my frontend.</p>
  
  <pre><code>def upload_image(request):
      random_filename = request.POST.get('random_filename')
      if request.is_ajax():
          if request.FILES:
              for file in request.FILES:
                  if file == "image":
                      img = request.FILES.get('image')
  
          else:
              img = request.POST.get('imageURL')
              img = img_from_url(img)
  
  
          session = boto3.Session(
              aws_access_key_id=AWS_ACCESS_KEY_ID,
              aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
          )
          s3 = session.resource('s3')
  
          s3.Bucket('****-bucket').put_object(Key='media/%s' % random_filename, Body=img, ContentType='image/png')
  </code></pre>
  
  <hr>
  
  <pre><code>def img_from_url(file):
      image_data = requests.get(file).content
      return ContentFile(image_data)
  </code></pre>